xsl-list
[Top] [All Lists]

Re: [xsl] Avoiding namespace generation in elements

2011-06-03 02:01:03
On 02/06/2011 18:29, Jacobus Reyneke wrote:
Good day,

I am transforming a XML file to XSD using Saxon and XSLT 2.0

I am manually creating the 'schema' element, since I am adding
namespaces to it. This causes Saxon in add
xmlns:xs="http://www.w3.org/2001/XMLSchema"; to each of the child
elements. Using exclude-default-prefixes="xs" has no effect.

Sample output:
<xs:schema targetNamespace="http://my.happydomain123.com/test/testing/1.0";
             xmlns:tt="http://my.happydonain123.com/test/testtypes/1.0";
             xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xs:simpleType xmlns:xs="http://www.w3.org/2001/XMLSchema"; name="Testing1">
    <xs:restriction base="xs:integer"/>
</xs:simpleType>
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema";
name="TestAgent2" type="tt:TestAgent"/>
</xs:shcema>

Crappy way of creating main schema that is causing the headache:
<xsl:value-of disable-output-escaping="yes">

Using d-o-e has many disadvantages, but I hadn't come across this one before! There's absolutely no need for this clumsy workaround. Use xsl:namespace to create the "dynamic" namespaces, and all will be well.

Michael Kay
Saxonica


&lt;</xsl:value-of>xs:schema targetNamespace="<xsl:value-of
select="$ns-map/namespaces/namespace[@pim-ns=$target-namespace and
@version=$target-namespace-version]/@namespace-uri"></xsl:value-of>"
             xmlns:xs="http://www.w3.org/2001/XMLSchema";
             <xsl:for-each select="$distinct-namespaces">
                 <xsl:variable name="pim-ns" select="./text()"
as="text()"></xsl:variable>xmlns:<xsl:value-of
select="$ns-map/namespaces/namespace[@pim-ns=$pim-ns and
@version=max($ns-map/namespaces/namespace[@pim-ns=$pim-ns]/@version)]/@prefix"></xsl:value-of>="<xsl:value-of
select="$ns-map/namespaces/namespace[@pim-ns=$pim-ns and
@version=max($ns-map/namespaces/namespace[@pim-ns=$pim-ns]/@version)]/@namespace-uri"></xsl:value-of>"
             </xsl:for-each>
elementFormDefault="qualified"<xsl:value-of
disable-output-escaping="yes">&gt;</xsl:value-of>

As you can see, I am creating namespace attributes on the fly, which
is why I can't just add<xs:schama>  as part of my xslt.

Kind regards,
Jacobus

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>