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

RE: Data-Dtriven node selection

Subject: RE: Data-Dtriven node selection
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Fri, 11 Mar 2005 22:04:35 -0500
data driven ui
Slight correction:

$data = a sequence of LR elements
$find = a sequence of Lookup elements

select="$data[@from=$find/@from]"

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross@xxxxxxxxxx
www.kronos.com

-----Original Message-----
From: Ross, Douglas [mailto:DRoss@xxxxxxxxxx]
Sent: Friday, March 11, 2005 10:03 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Data-Dtriven node selection

I am not sure where in the script you need this but the technique you
want is something like this:

$data = the LR elements
$find = the Lookup elements

select="$data/LR[@from=$find/@from]"

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross@xxxxxxxxxx
www.kronos.com

-----Original Message-----
From: David Laub [mailto:dlaub@xxxxxxxxxxx]
Sent: Friday, March 11, 2005 9:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Data-Dtriven node selection

I may be attempting the impossible.  Or I just may be
too stupid to figure it out

What I want to do is this: use a xml file to specify
which nodes from another xml file to select using a
data-driven xslt template.

For example:

1) My base xml file (LR.xml) , from which I want to
select nodes in a data-drivem manner

<LR>
	<Name>David Laub</Name>
	<Age>53</Age>
	<Addr>4645 W. Jerome</Addr>
	<Telephone>847-674 2266</Telephone>
	<City>Skokie</City>
	<State>IL</State>
</LR>

2) My data-driven "selector" file (LRLookup1.xml) -
the intent being for this specific example to select
only the name & city nodes - I also want to rename the
nodes.

<LRLookUp1>
	<Element from="LR/Name" to="Name"/>
	<Element from="LR/City" to="HomeTown"/>
</LRLookUp1>

3) Finally my stylesheet (GenericLRFiler.xsl) - which
doesn't quite work - I associate it with LRLookup1.xml
and the stylesheet then explicitly also reads the
LR.xml file

The key line is:

<xsl:value-of select="$LossReport/./@from"/>

That's the line that fails: I want to append in a
data-driven manner the specific nodes to the existing
node-tree in the variable $LossReport.  The XPath
isn't smart enough to know I want to evaluate ./@from
(which holds LR/Name & LR/City from the data-driven
selector file) I guess it just thinks I'm appending
the string ./@from as part of the XPath, which returns
nothing

I can succesfully hard code a specific node

<xsl:value-of select="$LossReport/LR/City"/>

but that defeats teh whole purpose of the whole
exercise!

Here's the full stylesheet

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="xml" indent="yes"/>
	<xsl:variable name="LossReport"
select="document('XSLT/LR.xml')"/>
	<xsl:template match="*">
		<xsl:element name="LRFilteredData">
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="/LRLookUp1/Element">
		<xsl:element name="{./@to}">
			<xsl:value-of select="$LossReport/./@from"/>
		</xsl:element>
		<xsl:apply-templates/>
	</xsl:template>
</xsl:stylesheet>

This is actual output:

<LRFilteredData>
	<Name></Name>
	<HomeTown></HomeTown>
</LRFilteredData>

what I want for output is:

<LRFilteredData>
	<Name>David Laub</Name>
	<HomeTown>Skokie</HomeTown>
</LRFilteredData>


So is this magic do-able?

Thanks in advance

David Laub

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.