|
Subject: Re: [xsl] Modifying namespace definitions in xs:schema elements From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 10 Oct 2009 15:22:54 -0400 |
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.)
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.
Does this mean that what I want to be done cannot be achieved at all, using XSLT techniques?
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: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>
-- 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, Michael Kay | Thread | Re: [xsl] Modifying namespace defin, G. Ken Holman |
| RE: [xsl] Modifying namespace defin, Michael Kay | Date | Re: [xsl] Modifying namespace defin, G. Ken Holman |
| Month |