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

Re: Using one nodeset to dictate the format of data fr

Subject: Re: Using one nodeset to dictate the format of data from another nodeset
From: "Rebecca O'Connell" <rebecca321@xxxxxxxxx>
Date: Thu, 7 Jun 2007 14:40:52 -0400
Re:  Using one nodeset to dictate the format of data fr
David assumed correctly that I had one document with two parts. Your
solution worked beautifully. I had a feeling that there was some
simple way I was missing. I am a much happier camper (see below for
the reason why I am not yet a completely happy camper).

I don't mind being corrected. I would much rather be told I'm using a
term incorrectly than continue using it incorrectly.

With regard to the second part of my question (how to "feed" a
template data from the template that called it), I am new to
parameters (and to XSLT) and am having some difficulty figuring out
how to handle them. Here's what I think I know about parameters:

1. xsl:param - used with stylesheets and templates, sets the parameter
2. xsl:with-param - used with apply-templates and call-template,
changes the default value of the parameter, passes the parameter to
the template being called (?)
3. xsl:value-of or select/name="{$paramName}" - used to get the value
of the parameter
4. Tunnel parameters "have the property that they are automatically
passed on by the called template to and further templated that it
calls, and so on recursively" (as described by Oxygen).

However, clearly I don't know enough, because my attempts to use
parameters are not working. Below is what I attempted:

   <content id="id1"><title>Title 1</title></content>
 <content id="id2"><title>Title 2</title></content>

 <topic-ref idref="id1" >
    <topic-ref idref="id2" />

 <div><h1>Title 1</h1>
   <div><h2>Title 2</h2></div>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:strip-space elements="*"/>

 <xsl:template match="/">
	<xsl:apply-templates select="x/structure-data"/>

<xsl:template match="topic-ref"> <xsl:param name="level" tunnel="yes" select="count(ancestor::*)"/> <div class="TOPIC-REF"> <xsl:apply-templates select="key('id', @idref)"> <xsl:with-param name="level" tunnel="yes" select="count(ancestor::*)"/> </xsl:apply-templates> <xsl:apply-templates select="topic-ref"/> </div> </xsl:template>

<xsl:template match="content">
       <xsl:apply-templates select="title" >
           <xsl:with-param name="level"/>

 <xsl:template match="title">
     <xsl:element name="{concat('h',$level)}">
         <xsl:value-of select="." />

 <xsl:key name="id" match="content" use="@id"/>

What am I getting wrong here?

Thank you,

On 6/7/07, David Carlisle <davidc@xxxxxxxxx> wrote:

> (David Carlisle is also making it more difficult, by giving you a lecture
> about what node-sets are. He's right of course, but you're not the only one
> to misuse the term).

yes, main reason I added that bit (in addition to the actual answer) was
that I couldn't tell what was meant by "2 node sets" as there was the
possibility that it meant two documents (since the input was shown as
two xml fragments). Misusing technical terms isn't  a sin and as
you say it's not uncommon, but sometimes it actually stops the question
being understood.


________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.

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.