[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: multi-document question
The default template rule for attributes copies the string value of the attribute as text. Either copy the attributes explicitly using <xsl:copy-of select="@*"/>, or write a template rule that copies them, <xsl:template match="@*"><xsl:copy/></xsl:template> Michael Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Bruce D'Arcus > Sent: 23 November 2003 05:50 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: multi-document question > > > > I'm a non-programmer relative newbie to xslt, and am stuck on the > following problem. I want to take this sort of file: > > <modsCollection> > <mods id="1"> > <abc>one</abc> > </mods> > <mods id="2"> > <abc>two</abc> > </mods> > </modsCollection> > > ...and to break it into individual files that exactly match > the content > of the mods element. I also want these files to be named > based on the > id attribute on the mods element. So, I'd like, for example, a file > called "1.mods" whose content is: > > <mods id="1"> > <abc>one</abc> > </mods> > > Below is what I have so far, which is getting me individual files > correctly named, but content like this: > > <?xml version="1.0"?> > <mods>oneone</mods> > > What am I doing wrong, and how do I fix it? > > Thanks, > Bruce > ================================ > <?xml version='1.0' encoding='utf-8'?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:exsl="http://exslt.org/common" > extension-element-prefixes="exsl"> > <xsl:output method="xml" version="1.0" encoding="utf-8" > indent="yes"/> > <xsl:strip-space elements="*"/> > > <xsl:template match="mods"> > <exsl:document href="{@id}.mods" method="xml"> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </exsl:document> > </xsl:template> > > </xsl:stylesheet> > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > 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
|