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

RE: Xpath and Ranges

Subject: RE: Xpath and Ranges
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 4 Aug 2006 15:07:12 +0100
RE:  Xpath and Ranges
> Here is the template where I am trying to grab a set of nodes 
> in order to wrap them in a parent node (since this is docbook 
> Im trying to wrap things in sect1)
> 
> <xsl:template match="for $T1 in (//title)[1], $T2 in 

The match attribute of xsl:template must be a pattern, it can't be a
generalized XPath expression. 

Use xsl:apply-templates to select the nodes that you want to process, use
xsl:template to define what processing to apply to the selected nodes.

I suspect that what you want might be something like:

<xsl:template match="/">
  <sect1>
    <xsl:copy-of select="for $T1 in (//title)[1], $T2 in (//title)[2] 
              return ($T1, //*[. &gt;&gt; $T1 and . &lt;&lt; $T2])"/>
  </sect1>
</xsl:template>

but not quite: because if there's an X element that passes the test, then
the children of X will probably pass it too, and if you copy X then you
don't want to copy its children, or they'll end up in the output twice.

So: you asked for an XPath expression that selected all the nodes between
the two titles, but I don't think that's what you really wanted. It might be
best to explain the real problem that you're trying to solve.

Michael Kay
http://www.saxonica.com/


> (//title)[2] return ($T1, //*[. &gt;&gt; $T1 and . &lt;&lt; $T2])">
> 	<xsl:element name="sect1">
> 	<xsl:apply-templates/>
> 	</xsl:element>
> </xsl:template>
> 
> I've installed Saxon 8.7.3N, and use XMLSpy with this commandline:
> c:\saxon\Transform.exe -o %2 %1 %3
> 
> The error I get is:
> 
> XSLT Pattern syntax error at char 0 on line 83 (the template 
> above), In {for $}: Unexpected token in patter, found "for"
> Failed to compile stylesheet, 1 error detected.
> 
> Hope that helps..let me know if I can supply any more information.
> 
> FYI the material Im apply this too is going to be open to the 
> public (its actually apart of the OGL, open gaming license).  
> So, Im trying to learn how to apply XPATH.
> 
> Thanks!
> 
> David White
> 
> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Friday, August 04, 2006 8:35 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Xpath and Ranges
> 
> > 
> > Could it be my software? XMLSpy 2006?
> > 
> 
> Does your xsl:stylesheet element specify version="2.0"? IIRC, 
> XMLSpy invokes a 2.0 processor when you specify 
> version="2.0", and a 1.0 processor otherwise.
> 
> Michael Kay
> http://www.saxonica.com/

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.