xsl-list
[Top] [All Lists]

[xsl] How to insert a snippet of XSD into HTML using serialize(), without the result containing a bunch of namespaces? Way to suppress the output of namespace declarations?

2015-06-12 08:05:22
Hi Folks,

I have this XML Schema:

-----------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                        xmlns:foo="http://www.foo.org";
                        xmlns:bar="http://www.bar.org";
                        xmlns:blah="http://www.blah.org";> 
    
    <xs:element name="Document">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Title" type="xs:string" minOccurs="0" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>
-----------------------------------------------------------------------------

I want to embed the Title element declaration into an HTML document. That is, 
when I view the HTML document in a browser I want this to display:

        <xs:element name="Title" type="xs:string" minOccurs="0" />

In my XSLT, I am using the new serialize function to output the Title element:

        <xsl:value-of select="serialize(//xs:element[@name eq 'Title'])" />

However, when I view the HTML document in a browser, I see a bunch of namespace 
declarations bundled with the Title element:

<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema";
         xmlns:foo="http://www.foo.org";
         xmlns:bar="http://www.bar.org";
         xmlns:blah="http://www.blah.org";
         name="Title"
         type="xs:string"
         minOccurs="0"/>

I don't want all those namespace declarations. How do I omit them?

I tried adding a serialization parameter to the serialize function:

<xsl:variable name="output-serialization-parameters" as="element()">
    <output:serialization-parameters 
xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization";>
        <output:omit-xml-declaration value="yes"/>
        <output:indent value="yes"/>
    </output:serialization-parameters>
</xsl:variable>

<xsl:value-of select="serialize((//xs:element[@name eq 'Title'], 
$output-serialization-parameters)" />

That had no effect.

Is there a serialization parameter to suppress the output of namespace 
declarations?

What is the solution to this problem?

/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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