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

Newbie: template matching and multiple document output

Subject: Newbie: template matching and multiple document output
From: Steve Perriman <sperriman@xxxxxxxxxxxx>
Date: Tue, 29 Jan 2002 16:08:05 -0000
steve perriman
Dear List,

This is my second attempt to post this problem. I have read all recent posts
on template matching but can't get the answer.

The aim is to convert the xml file below into: 1) an index page in html,
with links to all sub-files - this uses template "id" and works fine, 2) one
html page for each "part", with the file name MSC01.html, MSC02.html, etc,
containing just the text from that part. The best I can get is one html
page, named MSC01.html, which contains the text from all the "parts".

I am using Instant Saxon 6.5 to perform the transformation.

Many thanks,

Steve Perriman
Intranet/Internet Support Technician
South Trafford College

PS:  If this one doesn't arrives in plain text, I shall have to use a
different mail server.

----------------------------------------------------------------------------
---
xml file
----------------------------------------------------------------------------
---
<document>
	<part id = "MSC01">  
		<par kind = "id">MSC01</par>  
		<par kind = "Section">Some text Some text Some text </par>  
		<par kind = "Title">Some text Some text Some text </par>  
		<par kind = "Leaflet_Sub-heading">Who is the programme
for?</par>  
		<par kind = "Leaflet_text">Some text Some text Some text
</par>  
		<par kind = "Leaflet_Sub-heading">How long does it take to
complete?</par>  
		<par kind = "Leaflet_text">Some text Some text Some text
</par>
      </part>
	<part id = "MSC02">  
		<par kind = "id">MSC02</par>  
		<par kind = "Section">Some text Some text Some text </par>  
		<par kind = "Title">Some text Some text Some text </par>  
		<par kind = "Leaflet_Sub-heading">Who is the programme
for?</par>  
		<par kind = "Leaflet_text">Some text Some text Some text
</par>  
		<par kind = "Leaflet_Sub-heading">How long does it take to
complete?</par>  
		<par kind = "Leaflet_text">Some text Some text Some text
</par>
      </part>     
</document>
 
----------------------------------------------------------------------------
---
xsl stylesheet
----------------------------------------------------------------------------
---

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" encoding="Windows-1252" />
<xsl:param name="dir">directory</xsl:param>

<xsl:variable name="file" select="system-property('file.separator')" />

	<xsl:template match="/">
	            
	            <xsl:call-template name="part" />
	</xsl:template>

   <xsl:template name = "part" match = "/document/part">

      <html>
         <head>
         </head>
         <body>
            <xsl:call-template name="id" />
            <xsl:call-template name="document" />
         </body>
      </html>

   </xsl:template>

   <xsl:template name="document" match="//@id">
   <xsl:for-each select = "part">
     <xsl:document href = "{//@id}.html" method = "html">
		<html>
			<head></head>
			<body>
                     <table border="0" width="100%" cellspacing="0"
cellpadding="2">
                     <xsl:element name="tr">
                     <xsl:element name="td">
				<xsl:call-template name= "kind" />
				<xsl:value-of disable-output-escaping="yes"
select="text()" />
                     </xsl:element>
                     </xsl:element>
                    </table></body>
		</html>
	</xsl:document>
   </xsl:for-each>
   </xsl:template>

   <xsl:template name="kind" match="/@kind">
      <xsl:for-each select="/*[@kind != '']">
      <xsl:element name="span">
      <xsl:attribute  name = "class" >
      <xsl:value-of select = "@kind"/>
   
      </xsl:attribute>
      <xsl:value-of select="." />
      </xsl:element>
      <xsl:element name="br" />
      <xsl:text>
      </xsl:text>
      </xsl:for-each>
   </xsl:template>
   
<xsl:template name="id" match = "//*[@kind = 'id']">
      <xsl:for-each select="//*[@kind = 'id']">
      <xsl:element name="a">
  
      <xsl:attribute  name = "class" >
      <xsl:text>id</xsl:text>
      </xsl:attribute>
      <xsl:attribute name = "href" >
      <xsl:value-of select="." /><xsl:text>.html</xsl:text>
      </xsl:attribute>
      
         <xsl:value-of select="." />
      
      </xsl:element>
      <xsl:text> </xsl:text>
      </xsl:for-each>
</xsl:template>
    
</xsl:stylesheet>
----------------------------------------------------------------------------
---


----------------------------------------------------------------------------
---------
This message is sent in confidence for the addressee only. It may
contain confidential or sensitive information. The contents are not to
be disclosed to anyone other than the addressee. Unauthorised
recipients are requested to preserve this confidentiality and to advise us
of any errors in transmission. Thank you
----------------------------------------------------------------------------
---------

 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.