xsl-list
[Top] [All Lists]

RE: Re: how to split one xml to multiple xml files

2004-04-30 14:03:03
xsl:document is an XSLT 1.1 element for outputting to different files. In saxon 
you can use it simply by changing your stylesheet version to 1.1.

An example from the Saxon documentation:

<xsl:template match="preface">
    <xsl:document href="{$dir}\preface.html">
        <html><body bgcolor="#00eeee"><center>
            <xsl:apply-templates/>
        </center><hr/></body></html>
    </xsl:document>
    <a href="{$dir}\preface.html">Preface</a>
</xsl:template>

-----Original Message-----
From: cknell(_at_)onebox(_dot_)com [mailto:cknell(_at_)onebox(_dot_)com]
Sent: Friday, April 30, 2004 1:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: Re: [xsl] how to split one xml to multiple xml files


XSL 1.0 doesn't have a way to do this, though many processors have extensions 
that will do this for you. How and if you do it depends on your processor. 
Consult the processor's documentation.  "Someone" who suggested using the 
document() function doesn't understand that its purpose is to read external XML 
files rather than to write them.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Qin Ding <qding(_at_)csc(_dot_)com>
Sent:     Fri, 30 Apr 2004 16:17:23 -0400
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  Re: [xsl] how to split one xml to multiple xml files


I tried to split a big xml file into multiple xml files based on the
<pg-nbr>.  If I have this:
<chapter>
   <section id="sc1">
       <subsection id="sb1">
          <pg-nbr id="p1"></pg-nbr>
          <pg-nbr id="p2"></pg-nbr>
          <pg-nbr id="p3"></pg-nbr>
          <pg-nbr id="p4"></pg-nbr>
       </subsection>
       <subsection id="sb2">
          <pg-nbr id="p5"></pg-nbr>
          <pg-nbr id="p6"></pg-nbr>
          <pg-nbr id="p7"></pg-nbr>
       </subsection>
   </section>
   <section id="sc2">
       <subsection id="sb3">
          <pg-nbr id="p8"></pg-nbr>
       </subsection>
       <subsection id="sb4">
          <pg-nbr id="p9"></pg-nbr>
          <pg-nbr id="p10"></pg-nbr>
       </subsection>
   </section>
</chapter>

I want to split above files to this file:
sc1sb1p1.xml
<chapter>
   <section id="sc1">
      <subsection id="sb1">
         <pg-nbr id="p1><pg-nbr>
      </subsection>
   </section>
</chapter>

sc1sb1p2.xml
<chapter>
   <section id="sc1">
      <subsection id="sb1">
         <pg-nbr id="p2><pg-nbr>
      </subsection>
   </section>
</chapter>

sc1sb1p3.xml
<chapter>
   <section id="sc1">
      <subsection id="sb1">
         <pg-nbr id="p3><pg-nbr>
      </subsection>
   </section>
</chapter>

etc and etc.

How do I write xsl logic?  How do I automatically generate the output file
name?  How do I go through the loop to create many, many smaller xml files?
In above example, I should have 10 xml files created.   Someone suggests
that I use xsl:document href="" to output the xml files.  I tried to use
that but I can't even compile my xsl file.  Can someone show me how to do
this, please?  Thank you very much.

Qin
----------------------------------------------------------------------------------------

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------




--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--




--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



<Prev in Thread] Current Thread [Next in Thread>