[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: Re: [xsl] how to split one xml to multiple xml files


Subject: RE: Re: [xsl] how to split one xml to multiple xml files
From: cknell@xxxxxxxxxx
Date: Fri, 30 Apr 2004 16:39:11 -0400

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@xxxxxxxxxx - email



-----Original Message-----
From:     Qin Ding <qding@xxxxxxx>
Sent:     Fri, 30 Apr 2004 16:17:23 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
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.
----------------------------------------------------------------------------------------


Current Thread
Keywords