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

RE: XPath statement for traversing a nested node struc

Subject: RE: XPath statement for traversing a nested node structure
From: "Kenny Akridge" <kakridge@xxxxxxxxxxxxx>
Date: Wed, 4 Feb 2004 17:21:06 -0500
xpath nested
The only way I know to do that in version 1.0 is to take a count() from
your context.  

The code I gave you will do that.  I might be misinterpreting you
though.


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of scott
gabelhart
Sent: Wednesday, February 04, 2004 4:53 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  XPath statement for traversing a nested node
structure

Kenny Akridge wrote:

>If you are looking for a simple count of each object within a node(not
a
>sum of objects that includes the table subnode), then both of these
will
>work:
>
><?xml version="1.0"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:template match="/">
>	<xsl:for-each select="//TABLE">
>		<xsl:value-of select="concat(count(DPROW/OBJECT),
>'&#160;')"/>
>	</xsl:for-each>
></xsl:template>
></xsl:stylesheet>
>
><?xml version="1.0"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:template match="/">
>	<xsl:apply-templates select="//TABLE"/>
></xsl:template>
>
><xsl:template match="TABLE">
>	<xsl:apply-templates select="DPROW"/>
></xsl:template>
>
><xsl:template match="DPROW">
>	<xsl:value-of select="concat(count(OBJECT), '&#160;')"/>
></xsl:template>
></xsl:stylesheet>
>
>However, if you need the sum then you will need to use some
>recurision(off hand this is what I am thinking).
>
>I think your problem with DPROW/OBJECT is that you are getting a count
>based on the first table context.
>
>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of scott
>gabelhart
>Sent: Wednesday, February 04, 2004 2:40 PM
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject:  XPath statement for traversing a nested node structure
>
>I need some assistance with traversing a nested xml input file
>structure.
>
>I need to determine between the begining of one nested structure and 
>another the number of occurances of a particular element.
>
>Example:
>
><TABLE><DPROW><OBJECT></OBJECT></DPROW></TABLE> would yield an
occurance
>
>of one OBJECT element using the XPath statement DPROW/OBJECT.
>
>The above XPath statement falls apart though when I introduce nested 
>structures.
>
><TABLE><DPROW><OBJECT></OBJECT><TABLE><DPROW><OBJECT></OBJECT><OBJECT><
/
>OBJECT></DPROW></TABLE></DPROW></TABLE>
>Inner most TABLE element has two OBJECT elements and the outer TABLE 
>element would yield one OBJECT element.
>
>What is a valid XPath statement need for traversing the nested xml 
>structure above?
>
>Any help would be greatly appreciated.
>
>- Scott
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  
>
Kenny,

I will try your suggestion above. I am having problems with XPath based 
upon my nested xml file structure.

Is there a XPath expression that while I am traversing my nested xml 
input file I can determine how many OBJECT elements exist between each 
<TABLE> </TABLE> structure or <DPROW></DPROW>. With the nesting 
structure of my xml input file I can have tables nested within dprows 
and objects within each of those dprows.

- Scott



 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.