[xsl] x-schema in source xml causing no matches...

Subject: [xsl] x-schema in source xml causing no matches...
From: "Wright, Warren" <Warren.Wright@xxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Jul 2004 18:38:45 -0500
Hi list,

The xml I am trying to transform has an xmlns declaration that has
"x-schema:" in it, as shown below.  When I try to transform it, I don't
match on any of the elements that are within that "x-schema:..." namespace.

I tried fixing this by adding
xmlns:src="x-schema:http://www.qa.dealertrack.com/schemas/dtapp_v2_0.xdr"; to
the stylesheet, but when I do this xml spy complains that my xslt is no
longer valid.  Specifically, it tells me "This file is not valid: Root
element of document 'filename.xslt' is either not defined in DTD/Schema
document or part of the wrong Namespace".

See below for the xml and xslt that shows this problem:

The xml my customer sends looks something like this (abbreviated version):

<root>
    <Scorex_Header>
        <Call_Number>4</Call_Number>
    </Scorex_Header>
    <dt_application active="yes" status="new" dtversion="2.0"
xmlns="x-schema:http://www.qa.dealertrack.com/schemas/dtapp_v2_0.xdr";>
        <key_data optout="no">
            <dt_lender_id>ETR</dt_lender_id>
        </key_data>
    </dt_application>
</root>

My XSLT looks like this (abbreviated):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="root">
        <root>
            <xsl:apply-templates/>
        </root>
    </xsl:template>
    <xsl:template match="dt_application" name="dtApplication">
        <dt_application>
            <xsl:element name="active">
                <xsl:value-of select="@active"/>
            </xsl:element>
                <xsl:apply-templates/>
        </dt_application>
    </xsl:template>
</xsl:stylesheet>

Assume that the given dt_application section of the input xml really is
valid according to the dtapp_v2_0.xdr...it isn't in the samples above
because I abbreviated the xml for purposes of making the email look cleaner.

Somehow, when the xml fragment doesn't match the xdr the xslt engine ignores
the namespace, and my xslt works completely, but in the true xml I receive
the dt_application section DOES match the xdr, and so my xslt doesn't match
on any of the elements within the dt_application section.

Thanks for any help!

Warren Wright

Current Thread