XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old April 6th, 2003, 12:42 PM
Illuvatar Illuvatar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 9 Illuvatar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 7th, 2003, 04:12 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
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>

?!?

Reply With Quote
  #3  
Old April 7th, 2003, 04:36 AM
Illuvatar Illuvatar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 9 Illuvatar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If I do that then all the text will be shown before all the comments.

Reply With Quote
  #4  
Old April 7th, 2003, 04:44 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
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.

Reply With Quote
  #5  
Old April 7th, 2003, 06:29 AM
Illuvatar Illuvatar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 9 Illuvatar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks . That's It!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML/XSL question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway