[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Forgive me for mistyping the last template rule where I inadvertently specified an element named "processing-instruction" instead of the node ... it should have been:
Note that text nodes are copied by the built-in template rules.
I hope this helps.
. . . . . . . . . . . Ken
At 2009-10-10 15:22 -0400, I wrote:
Re: [xsl] Modifying namespace definitions in xs:schema elements
Subject: Re: [xsl] Modifying namespace definitions in xs:schema elements From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 10 Oct 2009 15:29:13 -0400 |
Forgive me for mistyping the last template rule where I inadvertently specified an element named "processing-instruction" instead of the node ... it should have been:
<xsl:template match="@* | comment() | processing-instruction()"> <xsl:copy/> </xsl:template>
Note that text nodes are copied by the built-in template rules.
I hope this helps.
. . . . . . . . . . . Ken
At 2009-10-10 15:22 -0400, I wrote:
At 2009-10-10 21:09 +0200, Wolfgang Laun wrote:given an XML Schema, I should split this schema into two parts, according to properties of elements and complex/simpleTypes. Basically, I've succeeded to do this, using a couple of XSLT transformations. But...
The original schema contains <xs:schema ... xmlns="a.b" targetNamespace="a.b" ...>. I would like to modify this for one of the results of the filtering, to become, e.g., xmlns="a.b.c" targetNamespace="a.b.c". (The ultimate goal is to separate the definitions made by the splt schemas into two different namespaces.)
Fine.
Exploring the set of attributes in xs:schema (by <xsl:choose> <xsl:when test="true()"> <xsl:value-of select="concat(namespace-uri(),local-name())"/>...) has shown me that the namespace definitions (xmlns="...") are not passed to template processing.
False.
Namespace definitions are not passed to template processing as attribute nodes, but they are passed to template processing as namespace nodes.
Does this mean that what I want to be done cannot be achieved at all, using XSLT techniques?
No, what you want can be done. I hope the example below helps.
. . . . . . Ken
T:\ftemp>type wolfgang.xml <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="a.b" targetNamespace="a.b">
<xs:element name="doc"> <xs:complexType> ... </xs:complexType> </xs:element>
</xs:schema>
T:\ftemp>xslt2 wolfgang.xml wolfgang.xsl
<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns="a.b.c" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="a.b.c">
<xs:element name="doc"> <xs:complexType> ... </xs:complexType> </xs:element>
</xs:schema> T:\ftemp>type wolfgang.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0">
<!--recreate the document element when encountered--> <xsl:template match="xsd:schema"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:copy-of select="@*"/> <!--replacing the target namespace information--> <xsl:namespace name="">a.b.c</xsl:namespace> <xsl:attribute name="targetNamespace">a.b.c</xsl:attribute> <!--rest of the document--> <xsl:apply-templates/> </xsl:element> </xsl:template>
<!--recostitute all other elements to avoid copying namespaces--> <xsl:template match="*"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:apply-templates select="@*,node()"/> </xsl:element> </xsl:template>
<xsl:template match="@* | comment() | processing-instruction"> <xsl:copy/> </xsl:template>
</xsl:stylesheet>
T:\ftemp>
-- Upcoming: hands-on code list, UBL, XSLT, XQuery and XSL-FO classes in Copenhagen Denmark and Washington DC USA, October/November 2009 Interested in other classes? http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Modifying namespace defin, G. Ken Holman | Thread | Re: [xsl] Modifying namespace defin, Wolfgang Laun |
Re: [xsl] Modifying namespace defin, G. Ken Holman | Date | Re: [xsl] Modifying namespace defin, Wolfgang Laun |
Month |
Keywords