Sandy wrote:
> Hi,
> I have the follwing XML and XSL files, i want to do XSL transformation but
> its not working because of the presence of xmlns="Science" in the Envelope
> element, It works fine after removing it.
in XML, non-prefixed names are endorsing the default namespace, which is
"Science" in your case
namespaces are working like families :
-<Envelope> is the firstname
-"Science" is the familyname
in XPath, non-prefixed names have no namespace
thus, in XSLT, as match="Envelope" is used without namespaces, it means
that you refer to :
-<Envelope> as the firstname
-no familyname
which is not the element that you have in your source document
in your XSLT document, you must deal with the XPath requirements :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns

sl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="Science">
^^^^^^^^^
<xsl:template match="foo:Envelope"><xsl:apply-templates/></xsl:template>
<xsl:template match="foo:Header"><xsl:value-of
select="foo:class"/></xsl:template>
</xsl:stylesheet>
-----------------------
notice that xmlns declarations should be non-relative URIs
URIs are just universal identifiers, that enforce familynames to be unique
xmlns="Science" is totally useless, because it might be not unique
xmlns="http://yourcompany.com/Science" is universally unique and ensures
that a name defined with :
-<Envelope>
-"http://yourcompany.com/Science"
can't be ambiguous
>
> I want to know how do i specify this namespace in XSL.
>
> file.xml
> <?xmlversion ="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xml" href="file.xsl"?>
> <Envelope
> xmlns="Science"><Header><class>A</class><activityName>Run</activityName><msg
> Name></Header></Envelope>
>
>
> file.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns
sl="http://www.w3.org/1999/XSL/Transform" xmlns="Science">
> <xsl:template match="Envelope"><xsl:apply-templates/></xsl:template>
> <xsl:template match="Header"><xsl:value-of select="class"/></xsl:template>
> </xsl:stylesheet>
>
> Thanks
>
>
--
Cordialement,
///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------