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

RE: transforming based on implicit cross-references

Subject: RE: transforming based on implicit cross-references
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Thu, 17 Dec 2009 20:47:55 +0100
RE:  transforming based on implicit cross-references
I haven't tested this but the snippet below should do the thing you

Robby Pelssers

<xsl:param name="personOfIntrest"/>

<xsl:template match="/">

<xsl:template match="timestamp[count(people/person = $personOfIntrest)
&gt; 0]">
    <xsl:apply-templates select="people/person[/text() =

<xsl:template match="person">
  <xsl:variable name="position" select="position()"/>
  <xsl:copy-of select="."/>
  <!-- copy the location at the same position -->
  <xsl:copy-of select="../locations/location[position() = $position]"/>

-----Original Message-----
From: FAIR, ED (ATTCINW) [mailto:EF7193@xxxxxxx]
Sent: Thursday, December 17, 2009 8:23 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  transforming based on implicit cross-references

I am a rank beginner using xslt 1.0 (Solaris 9 xsltproc) and I am being
provided xml data as in this example:


		<person>	Peter	</person>
		<person>	Robert	</person>
		<person>	Anna	</person>
			<location>	New York	</location>
			<location>	Zurich		</location>
			<location>	Hong Kong 	</location>
		<person>	Anna	</person>
		<person>	Peter	</person>
		<person>	Jason	</person>
		<person>	Robert	</person>
			<location>	Tokyo 	</location>
			<location>	Trenton	</location>
			<location>	Zurich	</location>
			<location>	Mumbai	</location>


Notice that:

- within each <timestamp> the count of "people/person" nodes == the
count of people/locations/location" nodes.  In the first <timestamp>,
there are
three people/person nodes, and there are three corresponding
people/locations/location nodes.  In the second <timestamp> there are

- The document order of timestamp/people/person corresponds to the
document order of timestamp/people/locations/location.  For example,
on 20091216 Anna was in Hong Kong; and on 20091217 Anna was in Tokyo.

- The document order of <person> can change:  in the First <timestamp>,
document order is:

	Peter, then Robert, then Anna;

in second <timestamp>, the document order is:

	 Anna, then Peter, then Jason, then Robert.

The names will always be distinct (there is always just one Anna, just
one Robert, etc).

My transformation needs to output just the locations for one person of
interest, for example, if I'm interested in Robert:

		<person>	Robert	</person>
		<location>	Zurich	</location>
		<person>	Robert	</person>
		<location>	Mumbai	</location>

Is this possible to perform this transformation in my environment?

Thank you in advance,


Current Thread


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.
First Name
Last Name
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.