[
Lists Home |
Date Index |
Thread Index
]
At 2003-08-29 15:16 +0100, Paul Spencer wrote:
>XSLT's handling of namespaces seems to be the bane of my life.
:{)}
>I need to be able to extract the default namespace from the
>xs:schema element.
>...
>I am using XSLT 1.0.
<xsl:value-of select="/*/namespace::*[name(.)='']"/>
I hope this helps.
................ Ken
T:\ftemp>type paul.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema
targetNamespace="example.com"
xmlns="example.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<test/>
</xs:schema>
T:\ftemp>type paul.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
Count: <xsl:value-of select="count( /*/namespace::* )"/>
default: <xsl:value-of select="/*/namespace::*[name(.)='']"/>
</xsl:template>
</xsl:stylesheet>
T:\ftemp>saxon paul.xml paul.xsl
Count: 3
default: example.com
T:\ftemp>
--
Next public European delivery: 3-day XSLT/2-day XSL-FO 2003-09-22
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide: please contact us for the details
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
|