XSL Transform trouble (XML newbie)

C

chris

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
 
C

chris

chris said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top