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

Re: Complex XPath Help

Subject: Re: Complex XPath Help
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 25 Apr 2002 22:12:42 +0200
asp tabs
Hi Mike,

what exactly is your problem? What's the stylesheet for your easier structure? For the complex one easily use preceding-axis.

An example:

<xsl:template match="tab">
    <xsl:text>preceding page:</xsl:text>
    <xsl:value-of select="preceding::tab/@page"/>
    <xsl:text>current page:</xsl:text>
    <xsl:value-of select="@page"/>
    <xsl:text>next page:</xsl:text>
    <xsl:value-of select="following::tab/@page"/>
</xsl:template>

Regards,

Joerg

Peet, Mike wrote:
Okay, it's probably not *that* complicated, but I'm having some trouble with
this one.  I think I'm missing something fundamental.  Sorry for the long
message.  For those of you that have the patience to look at this, your help
is greatly appreciated.

<xml>
   <tab-groups>
      <tab-group id="100" name="group1">
         <tabs>
            <tab desc="Page 1" page="page1.asp"/>
            <tab desc="Page 2" page="page2.asp"/>
         </tabs>
      </tab-group>
      <tab-group id="104" name="group2">
         <tabs>
            <tab desc="Page x" page="pagex.asp"/>
            <tab desc="Page y" page="pagey.asp"/>
         </tabs>
         <tab-group id="145" name="group3">
            <tabs>
               <tab desc="Page A" page="pageA.asp"/>
               <tab desc="Page B" page="pageB.asp"/>
            </tabs>
         </tab-group>
         <tab-group id="167" name="group3">
            <tabs>
               <tab desc="Page A" page="pageA.asp"/>
               <tab desc="Page B" page="pageB.asp"/>
            </tabs>
         </tab-group>
      </tab-group>
   </tab-groups>
</xml>

With the above XML document, if I pass a "page" into the XSLT as a
parameter, and I want to know what the previous and next pages are, how
would that be done?  Note that the tab-groups may be nested.

The desired behaviour is that the previous page would be simply the page
attribute of the preceding <tab> element (in document order, regardless of
group), and next would be the page attribute of the following <tab> element
(in document order, regardless of group).  The special cases of first and
last pages can return nothing.

One way that I can think of is an intermediate transform to get a document
containing just the <tab> elements with no nesting, and using the
preceding-sibling and following-sibling axes off the current tab, like this:

<xml>
   <tabs>
      <tab group-id="100" desc="Page 1" page="page1.asp"/>
      <tab group-id="100" desc="Page 2" page="page2.asp"/>
      <tab group-id="104" desc="Page x" page="pagex.asp"/>
      <tab group-id="104" desc="Page y" page="pagey.asp"/>
      <tab group-id="145" desc="Page A" page="pageA.asp"/>
      <tab group-id="145" desc="Page B" page="pageB.asp"/>
      <tab group-id="167" desc="Page A" page="pageA.asp"/>
      <tab group-id="167" desc="Page B" page="pageB.asp"/>
   </tabs>
</xml>

But this seems to defeat the purpose of a having a nice structured XML
document in the first place.  I would like to be able to accomplish this
without another transform, but I cannot seem to come up with the correct
XPath.. :(

Well, back to the XSL; thanks in advance!

Michael Peet
Software Engineer
Choice One Communications
100 Chestnut Street, Suite 600
Rochester, NY 14604
mpeet@xxxxxxxxxxxxxxxx
(585) 530-2773


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.