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

RE: Evaluate a string to a node set?

Subject: RE: Evaluate a string to a node set?
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Thu, 3 Aug 2000 10:16:00 +0100
xsl evaluate string
Think of your HTML as your stylsheet/template and instead of using
<xdata> where you want the xlm to be inserted put <xsl:value-of
select="driver[name = 'Schumacher']/date-of-birth" etc.
Ciao Chris

>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Hitchman, Andrew
>Sent: 03 August 2000 09:40
>To: XSL-List@xxxxxxxxxxxxxxxx
>Subject: Evaluate a string to a node set?
>
>
>Hi,
>
>To allow our HTML designers to concentrate on writing HTML with existing
>tools
>(like Dreamweaver) we are attempting to separate HTML presentation layout
>from
>XML data.
>
>So, out HTML designer would create team.html as below and use the tag
><xdata>
>to reference the XML data provided by our application. The stylesheet uses
>the XML
>document as the root and includes the HTML. On matching the <xdata> element
>in
>the HTML document the XSLT processor substitutes the value from the XML
>document
>and for a named node this works fine (actually in the example
>below it works
>only by
>virtue of the fact that the first name element is the team name).
>
>See end of message for an example of what I mean.
>
>But what we really need to be able to do is specify a path in the xdata
>select attribute,
>e.g.
>
>   <xdata select="team/notes">
>or
>   <xdata select="driver[1]/name">
>or
>   <xdata select="driver[name = "Schumacher"]/date-of-birth">
>
>and whilst
>
>   <xsl:template match="xdata" mode="presentation">
>      <xsl:variable name="this" select="."/>
>      <xsl:value-of select="$data//*[name(.) = $this/@select]/>
>   </xsl:template>
>
>will work where @select is limited to a node name, there doesn't seem to be
>a way to match
>a path represented as a string, for example (fictionally):
>
>   <xsl:value-of select="$data//*[. =
>node-set-matching-string($this/@select)]/>
>
>Is there something I'm missing?  (FYI, I'm using Xalan).
>
>I know that this whole approach seems a bit daft given that XSLT
>can convert
>the XML
>document into the HTML shown without any problem at all, but this
>would mean
>losing
>the use of our visual development tools for creating the HTML. And moreover
>this radical
>split of presentation and data seems much more robust and maintainable than
>direct
>transformation from XML to HTML.
>
>Cheers,
>
>Andy Hitchman.
>
>
>Example:
>============
>team.html
>-------------------------
><html>
>   <head>
>      <title>View Team <xdata select="name"/></title>
>   </head>
>   <body>
>      <h1>Team <xdata select="name"/></h1>
>      <xdata select="notes"/>
>   </body>
></html>
>
>team.xml
>--------------------------
><team>
>   <name>Ferrari</name>
>   <notes>Bla-bla-bla...</notes>
>   <driver>
>      <name>Schumacher</name>
>      <date-of-birth>1969-01-03</date-of-birth>
>   </driver>
>   <driver>
>      <name>Irvine</name>
>      <date-of-birth>1965-11-10</date-of-birth>
>   </driver>
></team>
>
>
>fragment of team.xsl (with team.xml at the root document)
>---------------------------
>...
><xsl:variable name="data" select="/"/>
><xsl:variable name="presentation" select="document("team.html")"/>
>
><xsl:template match="/">
>   <xsl:apply-templates/>
><xsl:template>
>
><xsl:template match="team">
>   <!-- Pass thru the html presentation -->
>   <xsl:apply-templates select="$presentation" mode="presentation"/>
></xsl:template>
>
><!-- For xdata in presentation html, insert the value from the xml
>document.
>-->
><xsl:template match="xdata" mode="presentation">
>   <xsl:variable name="this" select="."/>
>   <xsl:value-of select="$data//*[name(.) = $this/@select]/>
></xsl:template>
>
><!-- For presentation html, pass thru unchanged. -->
><xsl:template match="@*|*" mode="presentation">
>   <xsl:copy>
>      <xsl:apply-templates select="@*|node()" mode="presentation"/>
>   </xsl:copy>
></xsl:template>
>...
>
>
>
> 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.