[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
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"><?xml version="1.0" encoding="ISO-8859-1"?> <translation> <xsl:apply-templates select="//page"/> </translation> </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')"/> <file> <xml><xsl:value-of select="$outputfile"/></xml> <xsl><xsl:value-of select="xstylesheet/@fileref"/></xsl> <out><xsl:value-of select="concat($path,'/',$name,'.html')"/></out> </file> </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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|