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

RE: document() revisited, final

Subject: RE: document() revisited, final
From: "Beckers, Marc" <Marc.Beckers@xxxxxxxxxxxxxx>
Date: Fri, 18 Feb 2000 12:35:59 +0100
RE: document() revisited
I don't want to leave this topic without
thanking you for all your help. What may
seem straight-forward to you is not so obvious for
non-programmers like myself. I have now
a solution that works. FYI:

A Perl script reads XHTML files into an XML
file, something like:

<mother>
  <file>files\overview.htm</file>
  <file>files\book1\page1.htm</file>
  <file>files\book1\chap1\page2.htm</file>
</mother>

The meat of my XSL:

<!-- Get attributes -->   
 <xsl:template name="copy.all.attrib">
  <xsl:for-each select="@*">
   <xsl:copy/>
  </xsl:for-each>
 </xsl:template>  
  
 <!-- Define filter, copy results plus attributes --> 
 <xsl:template name="filter">
  <xsl:if test="not(boolean(@lang)) or ( @lang !='german' and @lang
!='french' )">
   <xsl:copy>
    <xsl:call-template name="copy.all.attrib"/>
    <xsl:apply-templates/>
   </xsl:copy>
  </xsl:if>
 </xsl:template>
 
 <!-- Identify old and new contents -->           
  <xsl:template match="file">
    <xsl:variable name="path" select="."/>
    <xsl:variable name="contents" select="document($path)"/>
    <xsl:variable name="newcontents">
      <xsl:for-each select="$contents">
       <xsl:apply-templates select="*"/>
      </xsl:for-each>
    </xsl:variable>
    
 <!-- "The name's Clark. James Clark." -->   
    <xt:document method="html" href="{$path}">
      <xsl:copy-of select="$newcontents"/>
    </xt:document>     
  </xsl:template> 
  
 <!-- Run the filter --> 
  <xsl:template match="*">
    <xsl:call-template name="filter"/>
  </xsl:template>

This has great potential for our "legacy" HTML documentation
(the "lang" and "dir" HTML attributes can be (ab)used for all sorts of
things...)
Thanks again,
Marc


 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.