My vote was going to be to update your EAD-to-HTML style sheet, but if you're dealing with a mix of DTD and schema-associated files, here's a style sheet that should transform your schema files into DTD-associated EAD instead:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- include the proper path to your DTD files in the doctype-system attribute-->
<xsl:output indent="yes" method="xml" encoding="utf-8"
doctype-system="/eadcb/shared/ead/ead.dtd"
doctype-public="+//ISBN 1-931666-00-8//DTD ead.dtd (Encoded Archival Description (EAD) Version 2002)//EN"/>
<xsl:strip-space elements="*"/>
<!-- Stylesheet to remove all namespaces from a document -->
<!-- NOTE: this will lead to attribute name clash, if an element contains
two attributes with same local name but different namespace prefix -->
<!-- Nodes that cannot have a namespace are copied as such -->
<!-- template to copy elements -->
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<!-- template to copy attributes -->
<xsl:template match="@*">
<xsl:choose>
<xsl:when test="local-name()='schemaLocation'"/>
<xsl:otherwise>
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- template to copy the rest of the nodes -->
<xsl:template match="comment() | text() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Granted, I just tested this with one file, but it seemed to do the trick. I found this example online and modified it slightly. Will that work for you?
Mark Custer
-----Original Message-----
From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Eric Lease Morgan
Sent: Tuesday, April 03, 2012 4:18 PM
To: [log in to unmask]
Subject: duplicate an xml file
Using XSLT, how can I duplicate an XML file sans namespaces?
I have a set of valid DTD-based EAD files that I transform into HTML using a XSL stylesheet. Tastes great and less filling.
I now have a set of valid schema-based EAD files but I can't transform them because namespaces get in the way.
My tentative solution to this problem is to copy the schema-based EAD file to new XML file sans the name spaces, and then transform the result, but my XPath statements are incorrect. This way I can use a single XSL stylesheet for HTML creation.
Here is a schema-based EAD snippet:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ead
xsi:schemaLocation = "urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd"
xmlns:ns2 = "http://www.w3.org/1999/xlink"
xmlns = "urn:isbn:1-931666-22-9"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<eadheader><!-- cool stuff here --></eadheader>
<archdesc level="collection"><!-- more cool stuff here --></archdesc>
</ead>
Here is a stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:template match="/">
<ead>
<xsl:copy-of select="/ead/eadheader"/>
<xsl:copy-of select="/ead/archdesc"/>
</ead>
</xsl:template>
</xsl:stylesheet>
The stylesheet works great if I remove all the name spaces from the EAD, but I can't do that because that is the whole point of the transformation. What sort of XPath statements do I need in order successful do the copy-of command?
--
Eric Lease Morgan
University of Notre Dame
|