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

Subject: RE: [xsl] x-schema in source xml causing no matches...
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 21 Jul 2004 09:47:55 +0100
You need to stop XML Spy from trying to validate your stylesheet against a
schema. I don't know the product well enough to know why it is trying to do
this, but it's this that is causing the trouble. 

After adding the namespace declaration to your stylesheet, you need to refer
to the dt_application element as src:dt_application.

Michael Kay

> -----Original Message-----
> From: Wright, Warren [mailto:Warren.Wright@xxxxxxxxxxxxxxxxxx] 
> Sent: 21 July 2004 00:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] x-schema in source xml causing no matches...
> 
> 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/dtap
> p_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