Subject: [xsl] Suppressing element content From: "Kirk Lowery" <empirical.humanist@xxxxxxxxx> Date: Wed, 10 Sep 2008 17:31:55 -0400 |
I'm using xsltproc on OS X 10.5 (Leopard), XSLT 1.0. I have an input xml file of n-ary trees. Here's a simplified example of the input: <Tree> <Node Cat="S" Head="0"> <Node Id="3.1" Cat="CL" Start="0" End="1" Rule="V2CL" Head="0" Type="Verbal"> <Node Id="3.2" Cat="V" Start="0" End="1" Rule="Vp2V" Head="0"> <Node Id="3.3" Cat="vp" Start="0" End="1" Rule="V2VP" Head="0"> <Node Id="3.4" Cat="verb" Start="0" End="1" Rule="VerbX" Head="0"> <Node Id="3.5" Cat="verb" Start="0" End="0" Lemma="SWR"> S71W.R </Node> <Node Id="3.6" Cat="x" Start="1" End="1" Lemma="H""> FH </Node> </Node> </Node> </Node> </Node> </Node> </Tree> What I want to do is to extract the contents of the Lemma attribute whenever the Cat attribute is "x" into a simple text file. Here is the stylesheet so far: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="Node[@Cat='x']"> <xsl:value-of select="@Lemma"/> </xsl:template> </xsl:stylesheet> Expected output (from this simplified example input): H What I get is: S71W.R H That is I get what I want, but I *also* get the contents of all Node elements but, interestingly I don't get the element content of the Node that is Cat="x". What I've read and researched today says I'm doing what I want, but obviously I'm missing something basic. Why am I getting all this extra Node element content of the file in the output? Thanks. Kirk
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Complicated next for-each, Martin Honnen | Thread | RE: [xsl] Suppressing element conte, Scott Trenda |
Re: [xsl] xslt sort dilemna, Mohit Anchlia | Date | RE: [xsl] Suppressing element conte, Scott Trenda |
Month |