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

RE: Not So Newbie XPath Question

Subject: RE: Not So Newbie XPath Question
From: DPawson@xxxxxxxxxxx
Date: Mon, 19 Feb 2001 14:16:31 -0000
xpath template match not
<?xml version = '1.0' encoding = 'utf-8'?> 
<!DOCTYPE xsl:stylesheeet
[
<!ENTITY nl "<xsl:text>&#x0A;&#xD;</xsl:text>">]>

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

  <xsl:output method="text"/>

 
<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>


<xsl:template match="z[a]">
  <xsl:if test="a">
    <xsl:apply-templates select="a"/>
  </xsl:if>

</xsl:template>


<xsl:template match="a[not(following-sibling::a)]" >
  <xsl:value-of select="name(following-sibling::*[1])"/>
</xsl:template>


</xsl:stylesheet>
I'm sure it could be simplified.
hth DaveP


> I have an XML structure of the following form:
> 
> <z>
>     <m/>
>     <n/>
>     <o/>
>     <a/>
>     <a/>
>     <a/>
>     <xp/>
>     <xq/>
>     <xr/>
> </z>
> 
> In the above structure is a sample. In the XML I will be 
> dealing with there is an
> arbitrary number of child elements of "z".
> Amongst the child elements there is a sequence of zero or 
> more "a" elements.
> I need an XPath expression to select/match the first element 
> after this sequence
> of "a" elements(if present). The first element's name after 
> the "a" sequence is unknown.
> In the above example it just happens to be "xp"
> 
> Is the following the most reasonable way to do it?
> 
> z/*[preceding-sibling::a and not(self::a)][position() = 1]
> 
> I have tested it and it seems to be ok. (Just does not seem 
> that intuitive)
> 
> Any thoughts appreciated,
> Bern
> 
>  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.