[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Template matching and use of <xsl:document>
>From: Steve Perriman <sperriman@xxxxxxxxxxxx> >To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> >Subject: Template matching and use of <xsl:document> >Date: Fri, 25 Jan 2002 17:49:34 -0000 >This is my first post, and the problem is similar to a couple of others that >have come up this week, but I am really stuck at this point. > >First though, I would like to say that finding out about XSL is proving to >be very useful. I am not a trained programmer and have been trying to >develop an intranet application without the use of ASP, etc. I have found >the basics of XSLT relatively clear to understand. > >In this case, the goal is to transform a single XML file, which contains my >college's course information, into multiple html files. For now, I am doing >this "off-line" using SAXON 6.5, but hopefully will move to a dynamic set up >like COCOON. The desired output is one html file containing links to all >the other pages - this is handled by the "id" template - and one html file >for each <part> element, with the attribute "id" providing the file name and >the "document" template to select the <part>. It also calls the "kind" >template - @kind is used to create inline styles in the output file. > >The links page is created fine, but the "document" template creates just one >file called MSC01.html, and this page contains all text of the whole source >file. I think I am going wrong with my select="" statements. > >By the way, although <xsl:document> seems to work in this setup, I, too, am >confused by the various recommendations, such as using <exsl:document>. >Some clarification would be appreciated. > >Many thanks. > >Steve Perriman >Intranet/Internet Support Technician >sperriman@xxxxxxxxxxxx > > >************ >xml instance >************ ><?xml version = "1.0" encoding = "UTF-8"?> ><?xml-stylesheet type="text/xsl" href="directory03.xsl" ?> ><document> > <documentinfo/> > <part id = "MSC01"> > <par kind = "id">MSC01</par> > <par kind = "Section">Mathematics & Science</par> > <par kind = "Title">GCSE Mathematics Foundation and >Intermediate Levels</par> > <par kind = "Leaflet_Sub-heading">Who is the programme >for?</par> > <par kind = "Leaflet_text">Students over 16 and mature >students.</par> > ... ... ... > </part> > <part id = "MSC02"> > <par kind = "id">MSC02</par> > <par kind = "Section">Mathematics & Science</par> > <par kind = "Title">GCSE Human Physiology and Health</par> > <par kind = "Leaflet_Sub-heading">Who is the programme >for?</par> > <par kind = "Leaflet_text">Students over 16 with an interest >in studying human biology.</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: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 = "*"> > <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 >---------------------------------------------------------------------------- -- ====================================================================== B. Tommie Usdin mailto:btusdin@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Phone: 301/315-9631 Suite 207 Direct Line: 301/315-9634 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|