xsl-list
[Top] [All Lists]

RE: Building a Manual with XML/XSL

2003-09-07 03:58:08
OK, Ken, Muluk thanks for your answers... Now I've seen apply-templates
would make my work easier... Now I'm thinking if it's possible to make a
node know which depth do he have in the tree, but with your examples I
could make the manual quite fast (for now).

By "hard PDF" I mean I realy have no idea about which software do I need
(I've seen Apache Forrest do the work quite well, but time to R&D is not
in my budget)

Using attributes as titles of my sections was just for an example. I have
not finished the XML structure yet (waiting my pals to finish the Word
versions of the doc then I will make the skeleton of the XML and then
everybody will follow this v2.0 model).

Now, imagine I want this manual to be included in a PHP/JSP page. Is there
any easy way to exclude everything but the body in the resulting HTML? I
would like to have a third version of the manual: HTML, PDF and HTML for
includes inside my website (in the middle of a table, for example).

I'm wondering also why xalan does not complain if I don't have a DTD/XSD
for my XML. Is not necessary?

And the last question, even less related to XSL: I want to make a little
script (shell script) to xalan all xml files in a directory structure.
As xalan needs the XSL file to apply to the XML I need to extract it from
the XML file. Anybody could tell me the regexp who could make this for me?
(I'm also open to any other parser suggestions)

Thanks!!!

Ivan


-----Mensaje original-----
De: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]En nombre de 
G. Ken Holman
Enviado el: sábado, 06 de septiembre de 2003 22:02
Para: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Asunto: Re: [xsl] Building a Manual with XML/XSL


At 2003-09-06 21:02 +0200, Iván Montoro Ten wrote:
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!)

It might seem scary, but it is as easy as for HTML, just with a different
output vocabulary.  There are two free book excerpts you can
download from
our web site to learn more and to use as reference material.  As well, we
are running two publicly-subscribed training courses in Europe in two
week's time that will cover *every* element, attribute and
function in XSLT
and *every* formatting object in XSL-FO.

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?

<xsl:for-each> is a "pull" approach to the information.

<xsl:apply-templates/> is a "push" approach to the information.  The free
excerpts give a characterization of these two approaches and
contrasts some
example stylesheets in each approach.

See a complete example using your data below that illustrates this push
approach.

I hope this helps.

............... Ken

p.s. I'm curious why you modelled your titles as attributes ... I would
recommend that language-oriented content be in #PCDATA and
machine-oriented
content be in attributes ... this will allow you to add structure
(emphasis, font style, etc) to portions of your titles ... if you leave
your titles as attributes, which cannot be structured, you will
be limited
in the future as your data matures.

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>


    <h1>To start...</h1>

    <p>text text text</p>

    <h2>What you need</h2>

    <p>text text text</p>


    <h2>Doing it well</h2>

    <p>text text text</p>

    <h3>Don't forget...</h3>

    <p>text text text</p>


    <p>text text text</p>




</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(_at_)CraneSoftwrights(_dot_)com
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


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





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