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?
And a second, related question: there is an xsi:schemaLocation that I
apparently need to include in the XML header. Attempts at using
<xsl:import-schema> and <xsl:namespace> haven't yielded correct
results. Would someone be willing to recommend a method for this? (See
the final example for my goal output).
I'm using XLST 2.0 and the Saxon-HE 9.2.0.6 in the oXygen editor.
Again, many thanks. Please excuse me if this has been beaten to death
- web searches and the list archives have so far refused to answer
this.
Best,
Bridger
My original XML looks something like this:
<root>
<row>
<title>Mice</title>
<author>Kat, Krazy</author>
<subject>bricks</subject>
<number>01101100011011110111011001100101</number>
</row>
</root>
And I'm processing with the following XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" media-type="text/xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="row">
<xsl:for-each select=".">
<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'"/>
<xsl:element name="dc:publisher">Ignatz Mouse
Publishers</xsl:element>
<xsl:element name="dc:creator"><xsl:value-of
select="child::author"/></xsl:element>
<xsl:element name="dc:title"><xsl:value-of
select="child::title"/></xsl:element>
<xsl:element name="dc:subject"><xsl:value-of
select="child::subject"/></xsl:element>
<xsl:element name="dc:identifier"><xsl:value-of
select="child::number"/></xsl:element>
</xsl:element>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Currently my results look like this:
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:publisher xmlns:dc="http://purl.org/dc/elements/1.1/">Ignatz
Mouse Publishers</dc:publisher>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kat,
Krazy</dc:creator>
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">Mice</dc:title>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">bricks</dc:subject>
<dc:identifier
xmlns:dc="http://purl.org/dc/elements/1.1/">01101100011011110111011001100101</dc:identifier>
</oai_dc:dc>
where I like to get results closer to this:
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
I arrived here by using my XSLT, Michael's cleaning XSLT, and then a
find/replace in the files.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--