[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Suppressing element content

Subject: RE: Suppressing element content
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Date: Wed, 10 Sep 2008 16:50:32 -0500
RE:  Suppressing element content
You need to override the built-in templates. And your initial template
is the same as the built-in template, so you don't need it.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:output method="text" />
	<xsl:template match="Node[@Cat='x']">
		<xsl:value-of select="@Lemma" />
	</xsl:template>
	<xsl:template match="@*|text()" />
</xsl:stylesheet>

~ Scott

-----Original Message-----
From: Kirk Lowery [mailto:empirical.humanist@xxxxxxxxx]
Sent: Wednesday, September 10, 2008 4:32 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Suppressing element content

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.