[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: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 7 Jun 2007 00:57:49 +0100
Re:  Using one nodeset to dictate the format of data fr
your posted input isn't well formed, but fixing that I think you just
want something like the code below

A note on terminology though

> I have two nodesets in a single XML document.

you're using xslt2 so it doesn't have a node set type, having been
replaced by sequence.

In a given document (in Xpath 1) there are always 2 to the n  node sets,
where n is the number of nodes, so always at least 4, (as there are
always at least 2 nodes in a well formed document) In XPath2 of course
there are infinitely many possible node sequences. You meant (I assume
from the example) there were two parts of the document of interest, or
perhaps you meant there were two input documents, I assumed the former
and added a container element <x> to your posted input.




> I would also like to be able to set the header levels within my
> content based on the depth of the content element. Is it possible to
> "feed" a template data from the template that called it?

Yes, template parameters do exactly that, but perhaps you just want
 count(ancestor::*)
, I'm not sure.

David





<x>
<source-data>
    <content id="id1">content-1</content>
  <content id="id2">content-2</content>
</source-data>

<structure-data>
  <topic-ref idref="id1" >
     <topic-ref idref="id2" />
  </topic-ref>
</structure-data>
</x>





<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
<xsl:strip-space elements="*"/>

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

  <xsl:template match="topic-ref">
    <div>
      <xsl:value-of select="key('c',@idref)"/>
      <xsl:apply-templates/>
    </div>
  </xsl:template>

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



$ saxon8 j.xml j.xsl
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>
   <body>
      <div>content-1
         <div>content-2</div>
      </div>
   </body>
</html>

________________________________________________________________________
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

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.