Jump to content
  • Advertisement
Sign in to follow this  
Enrico

XSL: copy subnodes and process some of them

This topic is 4132 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am currently trying to get the following result (HTML):
Microsoft has issued five new bulletins providing patches to solve
  several problems.  Due to the criticlality of some of the problems the
  application of the patches is highly recommended. Microsoft
from this piece of XML code:
<body tg-ref="en-admin"  headline="Summary">
  Microsoft has issued five new bulletins providing patches to solve
  several problems.  Due to the criticlality of some of the problems the
  application of the patches is highly recommended. <elink target="http://www.microsoft.com">Microsoft</elink>
</body>
The problem is to copy the text from the body-node and process the child nodes as well. And in the end, everything must fit together. My current approach is to iterate along the descendant-or-self axis and process depending on the node type:
<xsl:for-each select="descendant-or-self::*">
<xsl:if test="name() = 'body'">
<xsl:value-of select="name()"/><xsl:copy-of select="."/>
</xsl:if>
<xsl:if test="name() = 'elink'">
  Got a link!
</xsl:if>
</xsl:for-each>
The result is not exactly what I need, but I think it is logical that I don't get what I need. The stylesheet copies the text of the body-node and concatenates the following nodes at the end of this text. Is there a way to get the required results? Maybe a two-pass algorithm where I first copy the body-node's contents and then process all the links in the second pass? Thanks, Enrico

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!