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

Re: Match pattern should get child content but gets si

Subject: Re: Match pattern should get child content but gets sib's content also
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 26 Apr 2002 14:10:44 -0400
xsl template match pattern
[Joerg Heinicke]
> Doug Zirbel wrote:

> Have a look at built-in templates:
> http://www.dpawson.co.uk/xsl/sect2/N1665.html
>

To spell this out a little more than Joerg did, your (Doug's) template never
gets called.  The built-in default template is producing all the text you
see.  You can demonstrate that by adding a template that matches every node
but outputs nothing.  Add this as the last template:

<xsl:template match='*'/>

Now nothing will be displayed.

Your problem is that the processor never gets to your template at all, since
there is no path specified from the root to get there.  You should put that
path into the select attribute of the calling template.  Here's one way (not
necesssarily the best but good for highlighting the point):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match='/moduleExternal'>
<results>
 <xsl:apply-templates select='//link/aValue'/>
</results>
</xsl:template>

<xsl:template match="aValue">
<xsl:value-of select="."/>
</xsl:template>

<xsl:template match='*'/>
</xsl:stylesheet>

Tom P

...
>
> > ====== Here's my simplified xml doc ========
> >
> > <?xml version = "1.0" encoding = "UTF-8"?>
> > <?xml-stylesheet href =
> > 'file:///C:/Documents%20and%20Settings/doug/My%20Documents/ADE3.xsl'
type =
> > 'text/xsl'?>
> >
> > <moduleExternal xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
> > <parm>
> > <link>
> > <aValue>Hello</aValue>
> > </link>
> > </parm>
> > <parm>
> > <constraint>
> > <aValue>OOPS</aValue>
> > </constraint>
> > <link>
> > <aValue>World</aValue>
> > </link>
> > </parm>
> > </moduleExternal>
> >
> > ======== AND THE XSL file ==========
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:template match="link/aValue">
> > <xsl:value-of select="."/>
> > <xsl:text> </xsl:text>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> > ====== I'm opening the xml file in IE6.0 and what I get is this =====
> >
> > Hello OOPSWorld
> >
> > =========== This may be obvious to everyone but I thought that a match
> > pattern of "link/aValue" would skip over the <aValue> child of
<constraint>
> > and get only <aValue> content that is a child of <link>.
> >
> > TIA for any help with this... I've not been able to successfully wade
> > through all of the posts in biglist.
> > Best regards,
> > Doug Zirbel
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.