[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Namespace handling question
On 14/05/2010 19:36, Bridger Dyson-Smith wrote:
All - thanks for reading. I'm trying to generate OAI records for a series of XML files; while I have the bulk of the processing working, I'm stuck on a namespaces issue. I understand how to include/add a namespace to my output file, I'm curious if there's a way to keep all of the namespace information in the XML header - primarily to keep things tidy. I've found a short XSL from Michael Kay on the dpawson website for cleaning up the XML after the initial transform and I've incorporated that as a second step in the process. Is there a good way to combine the two? That is the default so you don't need to declare this template.
xsl:for-each iterating over . is a no-op so thi scan be omitted You only need xsl;element and xsl:namespace if these are going to use values dynnamically generated at run time.<xsl:result-document href="{concat(child::title, child::number, '.xml')}"> <xsl:element name="oai_dc:dc"> <xsl:namespace name="oai_dc" select="'http://www.openarchives.org/OAI/2.0/oai_dc/'"/> <xsl:namespace name="xsi" select="'http://www.w3.org/2001/XMLSchema-instance'"/> so the above could be written <oai_dc:dc> as all these namespaces are already in scope although you say above you want a schemalocation attribute, this is not a special attribute to xsl so you just generate it as any other, so for example as a lteral result element attribute <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> so putting it together and ignoring the xsl:result-document for now I think you want something like
<xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="row"> <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:publisher>Ignatz Mouse Publishers</dc:publisher> <dc:creator><xsl:value-of select="author"/></dc:creator> <dc:title><xsl:value-of select="title"/></dc:title> <dc:subject><xsl:value-of select="subject"/></dc:subject> <dc:identifier><xsl:value-of select="number"/></dc:identifier> </oai_dc:dc> </xsl:template> </xsl:stylesheet> which produces
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:publisher>Ignatz Mouse Publishers</dc:publisher> <dc:creator>Kat, Krazy</dc:creator> <dc:title>Mice</dc:title> <dc:subject>bricks</dc:subject> <dc:identifier>01101100011011110111011001100101</dc:identifier> </oai_dc:dc>
|
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
|