Re: [xml] Re: libxslt question



On Tue, 2004-03-02 at 10:24, Lucas Brasilino wrote:
Hi

    It's a XSLT question, not a libxslt question. Take a look at
<xsl:document> element at XSLT specs.


Thanks. I was looking at an old draft of XSLT (1999) which didn't have 
that element. However, I'm still not sure how to use it.

      Sure... <xsl:document> is not defined in XSLT 1.0.

Which function does the actual writing of these sub-documents? And what

      Just apply stylesheet with xsltApplyStylesheet(). Yes.. is that
easy :) Take a look at John Fleck's libxslt tutorial

happens if the stylesheet tries to place them in directories that do not 
exist, will those then be created? I'm asking because the document names

      Sure it will not create directories, AFAIK. It will raise an
I/O error.

and directories they are places in should in my case be derived from the 
input data.

      No problem. Take a look in this small example. What you have
to do is create output document path/file within href attribute of
<xsl:document>.


regards
      Lucas Brasilino

<?xml version="1.0" ?>
<doc>
   <foo name="first">
     <text>Foo 1</text>
   </foo>
   <foo name="second">
     <text>Foo 2</text>
   </foo>
</doc>

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:output method="html"/>

   <xsl:template match="/">
     <xsl:apply-templates/>
   </xsl:template>

   <xsl:template match="foo">
     <xsl:document href="{concat('out',position(),'.html')}">
       <xsl:for-each select="text">
      <html>
        <head>
          <title><xsl:value-of select="."/></title>
        </head>
        <body>
          <h1><xsl:value-of select="."/></h1>
        </body>
      </html>
       </xsl:for-each>
     </xsl:document>
   </xsl:template>
</xsl:stylesheet>

Are you using xsl:document to create separate output files?  That isn't
what it does.  The xsl:document function imports additional XML files
for processing.  What you want is the (very poorly named) exsl:document
extension function.

http://www.exslt.org/exsl/elements/document/index.html

Discussion of this belongs on a dedicated XSLT list, or the EXSLT list,
rather than the libxml2 or libxslt lists.

http://www.mulberrytech.com/xsl/xsl-list/

http://lists.fourthought.com/mailman/listinfo/exslt

Unless, of course, you want to discuss the actual implementation of
exsl:document in libxslt, in which case the discussion should be taken
to the libxslt mailing list.

--
Shaun





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]