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?


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

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