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

RE: read/write in the same xml file

Subject: RE: read/write in the same xml file
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Fri, 13 Jun 2003 14:03:19 +0100
word template xml
Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of abbouh
> Sent: Tuesday, June 10, 2003 4:25 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  read/write in the same xml file
> 
> 
> is there some propositions?
> 
(...)

If you only need to write a TOC you could try this stylesheet. You'll need a
node-set function, so you'll need to change the microsoft namespace to the
one used by your processor

Hope that this helps you.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt">
 <xsl:variable name="head" select="'paragraph'"></xsl:variable>
 
 <xsl:template match="document">
  <xsl:text>table of contents:&#10;</xsl:text>
  <xsl:apply-templates select="para">
   <xsl:with-param name="sizes">
    <xsl:apply-templates select="para" mode="psize"></xsl:apply-templates>
   </xsl:with-param>
  </xsl:apply-templates>
  <xsl:text>&#10;&#10;</xsl:text>
  <xsl:apply-templates select="para" mode="display"></xsl:apply-templates>
 </xsl:template>
 
 <xsl:template match="para">
  <xsl:param name="sizes"></xsl:param>
  <xsl:variable name="pos" select="position()"></xsl:variable>
  <xsl:variable name="cur"
select="ms:node-set($sizes)/count[position()=$pos]"></xsl:variable>
  <xsl:value-of select="concat($head,$pos,'&#9;')"/>
  <xsl:value-of select="sum($cur/preceding-sibling::count/word) +
(string-length(concat($head,$pos)) + 2) *
(count($cur/preceding-sibling::count ) + 1)"/>
  <xsl:text>&#9;</xsl:text>
  <xsl:value-of select="sum($cur/preceding-sibling::count/word) +
sum($cur/word) + (string-length(concat($head,$pos)) + 2) *
(count($cur/preceding-sibling::count ) + 1)"/>
  <xsl:text>&#10;</xsl:text>
 </xsl:template>
 
 <xsl:template match="para" mode="psize">
  <count>
   <xsl:apply-templates mode="psize"></xsl:apply-templates>
  </count>
 </xsl:template>
 
 <xsl:template match="word" mode="psize">
  <word><xsl:value-of select="string-length(.) + 1"/></word>
 </xsl:template>
 
 <xsl:template match="para" mode="display">
  <xsl:value-of select="concat($head,position(),'&#10;')"/>
  <xsl:apply-templates select="word" mode="display"></xsl:apply-templates>
 </xsl:template>
 
 <xsl:template match="word" mode="display">
  <xsl:apply-templates></xsl:apply-templates>
  <xsl:text>&#10;</xsl:text>
 </xsl:template>
</xsl:stylesheet>


 



 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.