[DDI-SRG] Trouble using XSLT with 3_0_CR
Matthew Richardson
matvey at isr.umich.edu
Mon Aug 13 13:36:13 EDT 2007
I'm having a bit of trouble writing XSLT that works with the latest instance
schema. For some reason, I can't get Cocoon to recognize the root element of
the file. I'm hoping this is something *I'm* doing in my XSLT, as opposed to
something with the schema. I used similar code on the pervious DDI3 version,
and had no problems.
Here's the URL:
http://staging.icpsr.umich.edu/cocoon/DSDR/CDG/chart.xml
Cocoon is following this pipeline:
<map:pipeline>
<map:match pattern="chart.xml">
<map:generate src="xml/DDI3/04402v3.xml"/>
<map:transform src="xslt/svgprep000.xsl" />
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
When it sees chart.xml it reads 04402v3.xml, which is just a snippet of XML,
really:
<?xml version="1.0" encoding="us-ascii"?>
<DDIInstance xmlns="ddi:instance:3_0_CR"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ddi:instance:3_0_CR
http://staging.icpsr.umich.edu/DDI/xsd/instance.xsd">
<MaintainableID xmlns="ddi:reusable:3_0_CR">
<ID>ICPSR_4402</ID>
</MaintainableID>
</DDIInstance>
I validated the XML; no problem there. The XSLT that renders it looks like
this:
<?xml version="1.0" encoding="us-ascii"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<test>
element: <xsl:value-of select="name()" />
</test>
</xsl:template>
</xsl:stylesheet>
It's just supposed to display one element...test...and the name of the root
element. I'm doing this for testing, because I can't seem to snag the root
element. Normally I do the first match thusly:
<xsl:template match="DDIInstance">
But that finds no match. Even though there's clearly a DDIInstance element
in the XML file.
<xsl:template match="/DDIInstance">
Also fails.
<xsl:template match="/">
Works, but it still doesn't see DDIInstance as the root element. I'm very
confused why the method I've been using for DDI2 and previous DDI3 version
suddenly fails.
Am I missing something obvious? I checked for issues of character encoding,
typos, and mac page breaks...I can't figure out what's changed.
Matthew
More information about the DDI-SRG
mailing list