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

recursive parsing?

Subject: recursive parsing?
From: Janning Vygen <vygen@xxxxxxxxxxxx>
Date: Fri, 20 Jul 2001 19:40:10 +0200
recursive parsing
i asked it before but i still cant get it to work.
Maybe there is some misunderstanding of xSL?? 
I hope not :-)

<book>
  <chapter id="ch1">
    <title>Example</title>
    <itemizedlist>
      <listitem>example a</listitem>
      <listitem>example b</listitem>
      <listitem>example c</listitem>
    </itemizedlist> 
  </chapter>
  <chapter id="ch2">
    <title>Example</title>
    <itemizedlist>
      <listitem>example d</listitem>
      <listitem>example e</listitem>
      <listitem>example f</listitem>
    </itemizedlist> 
  </chapter>
  <chapter>
    <ext:sitemap/>
 <!-- ^^^^^^ important -->
  </chapter>
</book>

i am using a docbook stylesheet. inveting the ext:sitemap tag where i 
want to put a sitemap. the sitemap should be designed just like a 
itemizedlist.

so i want my stylesheet to match ext:sitemap and to generate xml like 
this:

<book>
  <chapter id="ch1">
    <title>Examples 1</title>
    <itemizedlist>
      <listitem>example a</listitem>
      <listitem>example b</listitem>
      <listitem>example c</listitem>
    </itemizedlist> 
  </chapter>
  <chapter id="ch2">
    <title>Examples 2</title>
    <itemizedlist>
      <listitem>example d</listitem>
      <listitem>example e</listitem>
      <listitem>example f</listitem>
    </itemizedlist> 
  </chapter>
  <chapter id="sitemap">
    <title>Sitemap</title>
    <itemizedlist>
      <listitem><link linkend="ch1">Examples 1</link></listitem>
      <listitem><link linkend="ch2">Examples 2</link></listitem>
      <listitem><link linkend="sitemap">Sitemap</link></listitem>
    </itemizedlist> 
  </chapter>
</book>

then in phase two i could parse it again with my genric docbook 
stylesheet. THIS IS EASY TO DO! But then i always have to parse the 
whole document and always generate the sitemap. it takes about 5 
Minutes on a huge website. not very smart

SO HOW ABOUT THIS:

I want to split all chapters to chunks and i want just to parse only 
one chunk at a time given a rootid parameter like it is shown in the 
docbook xsl (html/chunk.xsl )

<xsl:template match="/">
  <xsl:choose>
    <xsl:when test="$rootid != ''">
      <xsl:choose>
        <xsl:when test="count(id($rootid)) = 0">
          <xsl:message terminate="yes">not found</xsl:message>
        </xsl:when>
        <xsl:otherwise>          
          <xsl:apply-templates select="id($rootid)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


That nice and it works, but i just cant get it to work if i only want 
to parse a specific chapter because you cant say:

[...]
       <xsl:otherwise>          
          <xsl:variable name="phase1">
            <xsl:apply-templates select="id($rootid)" mode="phase1">
          </xsl:variable>
          <xsl:apply-templates select="$phase1">
        </xsl:otherwise>
[...]


in the second step the rest of the document went out of scope!!
I have lots of trouble with this. I would like to parse some tags and 
send the output back to the input tree.

I have always trouble with fraction node trees. 

If you have a fraction node tree like this you cant parse it anymore 
with <xsl:apply-templates select="$nodetree">
because all the links will break.

<itemizedlist>
      <listitem><link linkend="ch1">Examples 1</link></listitem>
      <listitem><link linkend="ch2">Examples 2</link></listitem>
      <listitem><link linkend="sitemap">Sitemap</link></listitem>
</itemizedlist> 

i dont know if you got the point but i really hate it that i just 
cant do it like this:

<template match="ext:sitemap">
  <xsl:variable name="phase1">
    <xsl:call-template name="generate-sitemap">
  </xsl:variable>
  <!-- $phase1 has now fragment node tree
    <itemizedlist>
      <listitem><link linkend="ch1">Examples 1</link></listitem>
      <listitem><link linkend="ch2">Examples 2</link></listitem>
      <listitem><link linkend="sitemap">Sitemap</link></listitem>
  -->
  <xsl:apply-templates select="$phase1">
</itemizedlist> 
</template>

IF this would work everything would be fine to me! But it dont and i 
cant get a work around which fits my needs.

Please help, cause i am dazed and confused about all this xsl.

janning

 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.