[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: splitting one xml into many xml documents using xs

Subject: Re: splitting one xml into many xml documents using xsl
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Fri, 09 Mar 2001 10:02:03 -0800
xslt splitting an xml
It depends on the processor you are using, for example with xalan you could
do something like (notice the 'redirect' extension) what I have included
below. It does not fit with your situation but you could probably derive
what you need from it. Also I used output as text as opposed to XML which
might be better for your needs.  You can also do the same thing in Saxon
(and probably others) but I have not used it yet.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lxslt="http://xml.apache.org/xslt"
    xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
    extension-element-prefixes="redirect">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:value-of select="count(//page)"/>
   <redirect:write file="pagelist.xml">&lt;?xml version="1.0"
encoding="ISO-8859-1"?&gt;
      &lt;translation&gt;
         <xsl:apply-templates select="//page"/>
      &lt;/translation&gt;
   </redirect:write>
</xsl:template>

<xsl:template match="page">
   <xsl:variable name="path" select="../@folder"/>
   <xsl:variable name="name" select="output/@filename"/>
   <xsl:variable name="outputfile"
select="concat($path,'/',$name,'_x.xml')"/>

      &lt;file&gt;
        &lt;xml&gt;<xsl:value-of select="$outputfile"/>&lt;/xml&gt;
        &lt;xsl&gt;<xsl:value-of select="xstylesheet/@fileref"/>&lt;/xsl&gt;
        &lt;out&gt;<xsl:value-of
select="concat($path,'/',$name,'.html')"/>&lt;/out&gt;
      &lt;/file&gt;
</xsl:template>

</xsl:stylesheet>




----- Original Message -----
From: "murali meraga" <meraga_m@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, March 09, 2001 9:47 AM
Subject:  splitting one xml into many xml documents using xsl


> Hi,
>
>   Here is details about my problem. I have the
> folloing adddress.xml document
>
> <?xml version="1.0" encoding="UTF-8"?>
>   <address_object>
>        <address1>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
>        </address1>
>        <address2>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
>        </address2>
>        <address3>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
>        </address3>
>  </address_object>
>
> and I want to split the above xml into the follwing
> xml documents. How can I do that using xsl?
>
> ------------address1.xml -------------
> <?xml version="1.0" encoding="UTF-8"?>
> <address1>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
> </address1>
>
> ----------addrees2.xml --------
> <?xml version="1.0" encoding="UTF-8"?>
> <address2>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
> </address2>
> ------------- address3.xml --------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <address3>
>            <name>x</name>
>            <street>1925 x street</street>
>            <city>x city</city>
>            <zip>0000</zip>
> </address3>
>
> Thanks in advance.
>

>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.