This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Evaluate a string to a node set?


Chris,

I've already tried this approach, but enclosing the presentation HTML within
the XSL stylesheet (or even including it as a template) causes problems with
HTML editors (Dreamweaver2 blows-up).

Moreover it doesn't fit with my overall strategy of separating presentation,
data and the logic which combines them.

One of my goals is the ability to present the same XML with the same
stylesheet in different HTML pages (i.e. different layout, same data). The
idea is to create HTML fragments from the XML to slice into a master HTML
document.

The 'correct' approach seems to be the multi-source document(), but without
the ability to evaluate a string to a node-set to then generate the required
fragment this seems doomed to failure.

I assume from the general lack of responses that what I need isn't possible.
Which is a bit of a shame. I guess the next stop is creating my own function
to do this (which I don't relish at all).

Andy.

-----Original Message-----
From: Chris Bayes [mailto:Chris@Bayes.co.uk]
Sent: Thursday, August 03, 2000 10:16 AM
To: xsl-list@mulberrytech.com
Subject: RE: Evaluate a string to a node set?


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@mulberrytech.com
>[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Hitchman, Andrew
>Sent: 03 August 2000 09:40
>To: XSL-List@mulberrytech.com
>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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]