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

How to parse a fragment result tree in the context of

Subject: How to parse a fragment result tree in the context of input tree
From: Janning Vygen <vygen@xxxxxxxxxxxx>
Date: Thu, 31 May 2001 17:20:24 +0200
parsing html list items
Hi

first time i didnt get any answer, so i try again and explain my problem 
again with a short example:

the key problem is, that i can apply stylesheet to a fragment tree which is 
created in a template, but this fragment tree doesnt know where it belongs in 
the source tree. 

the second template generates a authorlist but can not include the proper 
class. How can you apply templates to a result tree fragment and still have 
access to the whole document??

i hope i  get some suggestion this time. but maybe i just cant properly 
explain my problem.

thanks in advance
janning

example.xsl:
<xsl:template match="authors">
  <xsl:variable name="authorlist">
     <itemizedlist>
       <xsl:for-each select="author">
         <listitem><xsl:value-of select="."/></listitem>
       </xsl:for-each>
     </itemizedlist>
  </xsl:variable>
  <xsl:apply-templates select="$authorlist"/>
</xsl:template>
<xsl:template match="itemizedlist">
  <ul>
    <xsl:attribute name="class">
      <xsl:value-of select="ancestor-or-self::chapter/@id"/>
    </xsl:attribute>
    <xsl:apply-templates/>
  </ul>
</xsl:template>


example.xml:
<book>
  <chapter id="first">
    <docinfo>
      <authors>
        <author>me</author>
        <author>myself</author>
        <author>and i</author>
      </authors>
    </docinfo>
    <itemizedlist>
      <listitem>normal</listitem>
      <listitem>list</listitem>
      <listitem>with items</listitem>
    <itemizedlist>
  </chapter>
  <chapter id="second">
    <itemizedlist>
      <listitem>another</listitem>
      <listitem>list</listitem>
      <listitem>with items</listitem>
    <itemizedlist> 
  </chapter>
</book>

html-result should be something like this:
<html>
<body>
<h1>chapter first</h1>
  written by 
  <ul class="first">
    <li>me</li> 
    <li>myself</li>
    <li>and i</li>
  </ul>
  <ul class="first">
    <li>normal</li>
    <li>list</li>
    <li>with items</li>
  </ul>
<h1>chapter second</h1>
  <ul class="first">
    <li>normal</li>
    <li>list</li>
    <li>with items</li>
  </ul>
</body>
</html>


 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.