Subject: Re: [xsl] splitting one xml into many xml documents using xsl From: Robert Koberg <rob@xxxxxxxxxx> Date: Fri, 09 Mar 2001 10:13:26 -0800 |
I grabbed the wrong xsl... to make the example more like what you need try this: <xsl:template match="/"> <xsl:value-of select="count(//page)"/> <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:apply-templates select="//page"/> </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')"/> <redirect:write file="$somename"> <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> </redirect:write> > </xsl:template> ----- Original Message ----- From: "Robert Koberg" <rob@xxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Friday, March 09, 2001 10:02 AM Subject: Re: [xsl] splitting one xml into many xml documents using xsl > 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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] concat bug in Oracle XSLT, Michael Kay | Thread | RE: [xsl] splitting one xml into ma, Joerg Pietschmann |
Re: [xsl] concat bug in Oracle XSLT, Steve Muench | Date | RE: [xsl] splitting one xml into ma, Chris Bayes |
Month |