Subject: Re: [xsl] Building a Manual with XML/XSL From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 06 Sep 2003 16:01:30 -0400 |
I'm building several manuals with XML for a product we make. I've seen several frameworks for it, but I'm looking for something easier, as a bare XML file and a XSL HTML transform (maybe later I'll get PDF, but that's too much for me right now!)
I've the basic skeleton for my document. I want XSL to transform this in a basic <P></P>, <H1></H1>, <H2></H2> structure, but I don't know how to iterate the subelements linearly, rather I know how to xsl:for-each them. Is there any solution for this?
T:\ftemp>type ivan.xml <?xml version="1.0" encoding="iso-8859-1"?> <manual> <chapter title="Begining with..."> <sub1 title="To start..."> <para>text text text</para> <sub2 title="What you need"> <para>text text text</para> </sub2> <sub2 title="Doing it well"> <para>text text text</para> <sub3 title="Don't forget..."> <para>text text text</para> </sub3> <para>text text text</para> </sub2> </sub1> </chapter> </manual>
T:\ftemp>type ivan.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <html><xsl:apply-templates/></html> </xsl:template>
<xsl:template match="sub1"> <h1><xsl:value-of select="@title"/></h1> <xsl:apply-templates/> </xsl:template>
<xsl:template match="sub2"> <h2><xsl:value-of select="@title"/></h2> <xsl:apply-templates/> </xsl:template>
<xsl:template match="sub3"> <h3><xsl:value-of select="@title"/></h3> <xsl:apply-templates/> </xsl:template>
<xsl:template match="para"> <p><xsl:apply-templates/></p> </xsl:template>
</xsl:stylesheet> T:\ftemp>saxon ivan.xml ivan.xsl <html>
</html> T:\ftemp>
-- Next public European delivery: 3-day XSLT/2-day XSL-FO 2003-09-22 Next public US delivery: 3-day XSLT/2-day XSL-FO 2003-10-13 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Building a Manual with XM, Mukul Gandhi | Thread | RE: [xsl] Building a Manual with XM, Iván Montoro Ten |
Re: [xsl] Building a Manual with XM, Mukul Gandhi | Date | Re: [xsl] xsltproc: process >1 incl, Daniel Veillard |
Month |