[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: x-schema in source xml causing no matches...
To follow up further, the most pressing question on the list below is why xml spy is telling me that my xslt document isn't valid. Here is an xslt that it complains about. Note that if you remove the 'src' namespace declaration, then xml spy is perfectly happy with it. However, everything I can google tells me that in order to match on a source document that has a namespace declaration I have to put that namespace in the xslt with a name that I can use on all of the matching statements.... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:src="x-schema:http://www.qa.dealertrack.com/schemas/dtapp_v2_0.xdr"> <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> Thanks for the help, Warren Wright -----Original Message----- From: Wright, Warren [mailto:Warren.Wright@xxxxxxxxxxxxxxxxxx] Sent: Tuesday, July 20, 2004 6:39 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: 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/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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|