Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL Transform trouble (XML newbie)

Reply
Thread Tools

XSL Transform trouble (XML newbie)

 
 
chris
Guest
Posts: n/a
 
      01-21-2004
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




 
Reply With Quote
 
 
 
 
chris
Guest
Posts: n/a
 
      01-21-2004
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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
blocking I/O with javax.xml.parsers.DocumentBuilder.parse() and javax.xml.transform.Transformer.transform() jazzdman@gmail.com Java 1 03-27-2005 06:56 AM
Is it possible to do a xsl transform on a string? Showjumper ASP .Net 1 07-03-2003 08:54 PM
Re: How do i transform an xml with 2 xsl files? Cowboy \(Gregory A. Beamer\) ASP .Net 1 07-03-2003 02:35 PM
What parses the xml/xsl transform in asp.net? System.xml NOT msxml? KathyB ASP .Net 0 06-25-2003 05:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57