RE: Scalability problem + solution

Subject: RE: Scalability problem + solution
From: DPawson@xxxxxxxxxxx
Date: Tue, 12 Oct 1999 15:07:44 +0100
Example of usage of multiple source and
output files.
Tks to David Carlisle for the advice.

Regards, DaveP

DTD - doc.dtd

<!ELEMENT doc (section)+>
<!ELEMENT section (p)+>
<!ELEMENT p (#PCDATA)>

Root file - doc.xml

<!DOCTYPE doc  SYSTEM "/sgml/mine/doc.dtd"[

<!ENTITY sect1 SYSTEM "sect1c.xml">
<!ENTITY sect2 SYSTEM "sect2c.xml">
<!ENTITY sect3 SYSTEM "sect3c.xml">
<!ENTITY dtd "IGNORE">
]>

<doc>

&sect1; <!-- Calls in the section *contents*, sans doctype -->
&sect2;
&sect3;
</doc>

section file - sect (n).xml

<!DOCTYPE doc SYSTEM "doc.dtd"[
<!ENTITY sect1c SYSTEM "sect1c.xml">
]>


&sect1c;     <!-- Similarly, calls in the *contents*, sans doctype -->
<!-- Above is duplicated for  n other files -->

Section 1 contents file sect1c.xml

 <section>
   <p>Para in section 1</p>

 </section>


Stylesheet

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [

<!ENTITY nbsp "&#160;"> 
<!ENTITY sp  "<xsl:text> </xsl:text>">

]>
  
<xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns:xt="http://www.jclark.com/xt";
    extension-element-prefixes="xt"
      version="1.0">


<xsl:output type="html"/>                          <!-- Main file -->

<xsl:template match="/">                        <!-- Only template -->
  <html>                        <!-- Main file output -->
<head>
   </head>
<body>

<p>This is from the stylesheet  </p>     <!-- Generated Text -->
  <xsl:for-each select= "//p">
                        <!-- Access all files from the root file -->
<p> <xsl:value-of select="."/> (Accessed from  root) </p>
</xsl:for-each>
</body>
</html>



 
    
                        <!-- Now generate one file per section -->
  <xsl:for-each  select="/doc/section">
  <xsl:variable name="docnumber">  <!--Generate a number from section posn
-->
    <xsl:number value="position()"
		format="1"/>
   </xsl:variable>
		              <!-- Append the number to the filename -->
   <xt:document method="html" href="sect{$docnumber}.html">
<html>
<head>
</head>
<body>
                        <!-- Output into the section files -->
    <p><xsl:value-of select="p"/> </p>
</body>
</html>
   </xt:document>                        <!-- End of sectional output -->
  </xsl:for-each>                        <!-- End of each section -->
 </xsl:template>                        <!-- End of template -->
</xsl:stylesheet>                        <!--End of stylesheet -->


Output (main file)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<p>This is from the stylesheet  </p>
<p>Para in section 1 (Accessed from  root) </p>
<p>Para in section 2 (Accessed from  root) </p>
<p>Para in section 3 (Accessed from  root) </p>
</body>
</html>

Output (sect1.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<p>Para in section 1</p>
</body>
</html>


Ditto for other output files, sect (n).html


Now I can edit the sections with emacs,
and nsgmls can validate it for me,
and xt can correctly number it for me across
section boundaries.

Delighted!

DaveP


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread