OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] chunking or splitting for non-html files


Jirka:

Thank  you for your very helpful response. I am copying to the mail list as well, I was trying to be considerate and not spam the list.
I made couple minor changes to the code, so that I can get the declaration in the output files, and got it to work well enough.
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<!-- ********************************************************************
        A style sheet to split out main doc into several smaller docs
     ********************************************************************-->
<!-- ==================================================================== -->
<xsl:output method="xml" doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN"
doctype-system="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
indent="yes" omit-xml-declaration="no"/>

<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
</xsl:template>
<xsl:template match="article">
  <xsl:variable name="filename">
    <xsl:number count="article"/>
  </xsl:variable>
  <xi:include href="{$filename}.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
  <xsl:result-document href="Art-{$filename}.xml">
    <xsl:next-match/>
  </xsl:result-document>
</xsl:template>
</xsl:stylesheet>
 

However I am running into an issue when I use this following stylesheet to sections and have a nested section
it errors saying it cannot write out to same URI.

Here is the Style Sheet
<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
</xsl:template>
<xsl:template match="section">
  <xsl:variable name="filename">
    <xsl:number count="section"/>
  </xsl:variable>
  <xi:include href="{$filename}.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
  <xsl:result-document href="Sect-{$filename}.xml">
    <xsl:next-match/>
  </xsl:result-document>
</xsl:template>
</xsl:stylesheet>
 
Here is a sample of the XML data
 <section>
       <title>
         <emphasis role="bold">DATA <indexterm significance="normal">
               <primary>DATA </primary>
            </indexterm>
         </emphasis>
      </title>
      <section>
         <title>SubData</title>
         <para>blah blah blah</para>
       </section>
      <section>
         <title>NEXT DATA<indexterm significance="normal">
               <primary>NEXT DATA</primary>
            </indexterm>
         </title>
         <para>Next Set of Data Blah blah blah</para>
         <programlisting format="linespecific">
         INTEGER value 10
         INTEGER value 11
         INTEGER value 12
         </programlisting>
      </section>
 </section>
 
How would you propose to modify the XSLT to handle the nested sections?
 
I tried to change the xsl:number to an xsl:select where it could name the result files as section/titles
but that was not successful.
How would you handle that? Was I on the right track with the xsl:select?
 
 
Thank you for your help!
/G.  
 

 
-----Original Message-----
From: Jirka Kosek <jirka@kosek.cz>
To: docbook-apps@lists.oasis-open.org <docbook-apps@lists.oasis-open.org>
Sent: Thu, Jul 22, 2010 9:54 am
Subject: Re: [docbook-apps] chunking or splitting for non-html files

gpevaco@aol.com wrote:

> Just to clarify this then is something that cant be done with XSLT 1.0?

Yes, it can be done, but you have to use proprietary extensions like
saxon:output or exsl:document. That's why I have used standard XSLT 2.0.

> Thank you once again for your help with this, like I said I am a newbie with 
XSLT.  
> It is greatly appreciated.

Please keep thread on mailing list by using "Reply All" so other users
can benefit from mailing list archive.

-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: jirka@kosek.cz      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
------------------------------------------------------------------


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]