Re: processing with xsl

XSLT and XPath questions would be better posted to the following list:

   http://www.mulberrytech.com/xsl/xsl-list

There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:

   http://www.dpawson.co.uk

At 2003-07-31 10:44 +0200, Marco Contardi wrote:
>I have this xml (sample XMLSpy generate from xsd)
>
><?xml version="1.0" encoding="UTF-8"?>
><?xml-stylesheet type="text/xsl" href="out_struttura_pra.xsl"?>
><PraPermessoZTL
>xmlns="http://www.saga.it/egov/esicra/importazione/xml/esicra_pra"
>xmlns:esicra_import="
>http://www.saga.it/egov/esicra/importazione/xml/esicra_import"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xsi:schemaLocation="
>http://www.saga.it/egov/esicra/importazione/xml/esicra_pra
>PraPermessoZTL.xsd">
>       <Pratica>
>             <Id>2147483647</Id>
>             <Oggetto>HELLO</Oggetto>
>       </Pratica>
></PraPermessoZTL>
>
>I process the xml with the following xsl
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:template match="/">
></xsl:template>
></xsl:stylesheet>
>
>The problem is that it don't work,
>It work only when I delete the row "xmlns="http://....." from xml
>Any ideas please?

Unprefixed elements and attributes in XPath expressions address constructs 
only found in no namespace.  When you use the default namespace in an XML 
instance, your constructs are in a namespace even though there is no 
prefix.  Therefore, in your XPath instructions in XSLT you are obliged to 
use a prefix, even though there is no prefix in your XML instance.

Namespace processing is not based on the prefix used, it is based on the 
URI associated with the elements and attributes through various techniques 
of using prefixes and declaring associated namespace URI strings.

The reason your stylesheet works when you remove the default namespace 
declaration from your instance is because you are changing all of your 
elements from in a namespace to no namespace and your unprefixed XPath 
addresses find the constructs.  When you put the namespace declaration back 
in, you are adding the URI back onto the constructs and your unchanged 
XPath addresses can no longer find them.  You are obliged to add prefixes 
to your XPath address steps in your stylesheet.

I hope this helps.

.................. Ken


--
Upcoming hands-on courses: in-house corporate training available;
North America public:                     XSLT/XPath Aug 12, 2003

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X              Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:    http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/x/bc

Received on Thursday, 31 July 2003 07:13:52 UTC