XSL Transform trouble (XML newbie)

Discussion in 'XML' started by chris, Jan 21, 2004.

  1. chris

    chris Guest

    Hello all -

    I am trying to display some XML data as html via a transform (XSLT). The
    XML data is as follows:

    <TopElement>
    <NextElement>
    <String1>AAAAA</String1>
    <String2>BBBBB</String2>
    <String3>CCCCC</String3>
    <String4>DDDDD</String4>
    </NextElement>
    </TopElement>

    There could be a great many <NextElement> nodes in the XML file. I want the
    resultant file (structure) to look like this:

    .... <stuff>
    <tr><td>
    <xsl:value-of select="String2">
    </td></tr>

    <tr>
    <td><xsl:value-of select="String3"></td>
    <td><xsl:value-of select="String4"></td>
    </tr>
    .... <more stuff>



    Where String2 might be a constant for several nodes. Using the
    <xsl:for-each select=""> structure, I get the value of String2 repeated over
    and over again when I want one instance of the value of String2 displayed
    and the other data displayed via the iteration (it will always be
    different). I can sort the value etc but can't get it to display the way I
    like. I have looked for a solution i the book I'm using (XSLT & XPATH) but
    no straightforward answer. Please let me know if I have not stated the
    problem correctly. Thank you in advance for any assistance.

    Regards,

    chris
    chris, Jan 21, 2004
    #1
    1. Advertising

  2. chris

    chris Guest

    chris wrote:

    > Hello all -
    >
    > I am trying to display some XML data as html via a transform (XSLT).
    > The XML data is as follows:
    >
    > <TopElement>
    > <NextElement>
    > <String1>AAAAA</String1>
    > <String2>BBBBB</String2>
    > <String3>CCCCC</String3>
    > <String4>DDDDD</String4>
    > </NextElement>
    > </TopElement>
    >
    > There could be a great many <NextElement> nodes in the XML file. I want
    > the resultant file (structure) to look like this:
    >
    > ... <stuff>
    > <tr><td>
    > <xsl:value-of select="String2">
    > </td></tr>
    >
    > <tr>
    > <td><xsl:value-of select="String3"></td>
    > <td><xsl:value-of select="String4"></td>
    > </tr>
    > ... <more stuff>
    >
    >
    >
    > Where String2 might be a constant for several nodes. Using the
    > <xsl:for-each select=""> structure, I get the value of String2 repeated
    > over and over again when I want one instance of the value of String2
    > displayed and the other data displayed via the iteration (it will always
    > be different). I can sort the value etc but can't get it to display the
    > way I like. I have looked for a solution i the book I'm using (XSLT &
    > XPATH) but no straightforward answer. Please let me know if I have not
    > stated the problem correctly. Thank you in advance for any assistance.
    >
    > Regards,
    >
    > chris
    >

    HI all -

    I figured it out ;-)

    For those interested, see:

    http://www.jenitennison.com/index.xml for good info on XSLT in general and
    http://www.jenitennison.com/xslt/grouping/index.xml for info regarding the
    problem outlines above in particular.

    Also, for those who don't know (like me) and are using C# to transform XML
    using keys, *don't* follow the MS example at MSDN. There is an identified
    problem with XmlDataDocument. See a solution here: http://tinyurl.com/2htx8.

    Thanks to all.

    --
    chris
    chris, Jan 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    0
    Views:
    1,003
    KathyB
    Jun 25, 2003
  2. Cowboy \(Gregory A. Beamer\)

    Re: How do i transform an xml with 2 xsl files?

    Cowboy \(Gregory A. Beamer\), Jul 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    296
    Showjumper
    Jul 3, 2003
  3. Anthony Harkness-Gripe

    Dataset to XSL Transform not displaying HTML--only XML

    Anthony Harkness-Gripe, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    979
    itnrant
    Jul 8, 2008
  4. Andy Dingley

    Re: Newbie: XSL transform with ASP

    Andy Dingley, Jun 26, 2003, in forum: XML
    Replies:
    3
    Views:
    2,305
    ddavis
    Jun 27, 2003
  5. Alan
    Replies:
    1
    Views:
    418
    Patrick TJ McPhee
    Jul 11, 2004
Loading...

Share This Page