xsl-list
[Top] [All Lists]

[xsl] XMLNS problem

2013-02-12 15:34:28
Dear all,

I have a namespace question I haven't been able to find an answer to, and none 
of the similar questions I've found on this list so far have helped.  I've 
never been able to get my head around namespaces, so if any of you can help, 
I'd be appreciative.

I'm working on a project using Encoded Archival Description (EAD), and trying 
to do minor adjustments to documents in order to make them compliant with a 
different version of the schema.  I'm doing this by using XSLT to do a complete 
copy of the input document, making changes to the output, but I can't get the 
correct schema information to appear in the new document.

Here's what the input documents look like:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ead PUBLIC "+//ISBN 1-931666-00-8//DTD ead.dtd (Encoded Archival 
Description (EAD) Version 2002)//EN" "http://rmoa.unm.edu/dtd/ead.dtd";>
<ead>
...
</ead>

In order for the output XML to be useful, heading needs to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<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";>
...
</ead>

The best I've been able to come up with produces the following:

<?xml version="1.0" encoding="UTF-8"?>
<ead 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="urn:isbn:1-931666-22-9&#xA; 
http://www.loc.gov/ead/ead.xsd";>
...
</ead>

This is close, but it doesn't include the xmlns line, which appears to be 
needed for it to validate correctly. The XSLT I have below seems like it should 
do what I want, but it produces an error in the xsl:namespace declaration.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:input="urn:isbn:1-931555-22-9" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    xmlns:ns2="http://www.w3.org/1999/xlink"; 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    exclude-result-prefixes="xs" version="2.0">
    <xsl:output method="xml"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="ead">
        <xsl:element name="ead">
            <xsl:namespace name="">urn:isbn:1-931666-22-9</xsl:namespace>
            <xsl:attribute name="xsi:schemaLocation">urn:isbn:1-931666-22-9
                http://www.loc.gov/ead/ead.xsd</xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>
...
</xsl:stylesheet>

Thanks in advance for any help you can provide!

All good wishes,
Eric
--~------------------------------------------------------------------
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>
--~--


<Prev in Thread] Current Thread [Next in Thread>