PDA

View Full Version : Trying to use XSLT to convert XML but exclude records I don't want


Christopher_amatulli
Jun 27, 2007, 09:41 AM
I'm trying to figure out how to get an XML file converted using XSLT to a flat text file... I am having 2 issues with this that I am hoping someone here can help me with.

issue 1: I want to exclude nodes based on a value of a attribute in a node. I already have a for-each running on that node, but I would like to know how to exclude them based on the value of the attribute of the node.

issue 2: how do I insert a CRLF during the transform...

hisham440
Sep 9, 2007, 07:11 AM
I Don't Know..
:(

Sitwonade
Feb 28, 2008, 12:54 PM
1.

<xsl:for-each select="//node[not(@attribute='value for which you want the node excluded')]">
<xsl:apply-templates/>
</xsl:for-each>

2.
create a variable with:

<xsl:variable name="CRLF">
<xsl:text>
</xsl:text>
</xsl:variable>
insert it with:

<xsl:value-of select="$CRLF"/>

edit: argh... even inside the code tags it's being eaten. It should be:
<xsl:text>ampersand pound one zero semicolon</xsl:text>
but actually type the charcaters (not the words) and no spaces.