|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
XML/XSL question
I'm trying to write an XSL stylesheet that transforms my XML into a nice html page. There's just one problem:
Code:
<doc>
<section>
<comment>Blabla</comment>
<text>I'm ugly</text>
<comment>Again a silly comment </comment>
</section>
</doc>
As you can see my <section> can contain either a comment or a text. The problem is, when I use apply-templates select="text" and apply-templates select="comment" first all the text is parsed and then all the comments .. so the all of the text comes before the comments, instead of the way it's in the XML file. Is there any way to preserve this order? I don't care how it's done, whether it's with a DTD or *anything*, as long as I can get the order right .. please? - Bram |
|
#2
|
|||
|
|||
|
Hmm, i don't know if i understand your problem, but why don't you first select the text node, than all other nodes?
<xsl:for-each select="text"> ... do something with the text node(s) </xsl:for-each> <xsl:for-each select="comment"> ... do something with your comments... </xsl:for-each> ?!? |
|
#3
|
|||
|
|||
|
If I do that then all the text will be shown before all the comments.
|
|
#4
|
|||
|
|||
|
Ahh, i guess i get it know, you want something like:
<xsl:for-each select="*"> <xsl:if test="name() = 'text'"> ... some text ... </xsl:if> <xsl:if test="name() = 'comment'"> ... some comment ... </xsl:if> </xsl:for-each> with "*" you'll get a IXMLDOMNodeList with all childnodes in sort order as in your document. |
|
#5
|
|||
|
|||
|
Thanks
. That's It! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML/XSL question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|