Re: [xsl] Generating the xml: namespace from XSLT into a schema

Subject: Re: [xsl] Generating the xml: namespace from XSLT into a schema
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 20 Jul 2002 17:51:43 +0100
Hi Danny,

> I have a stylesheet that builds a Schema. In this schema I need to
> output the xml:lang attribute on some elements in this schema. My
> stylesheet creates the schema import statement as well as creating
> the xml:lang attributes at the right place. The problem is I don't
> get a namespace declaration at the top of the schema which the IBM
> quality checker and MSV complain about.

The Namespaces in XML Rec. states:

  The namespace prefix, *unless it is xml* or xmlns, must have been
  declared in a namespace declaration attribute in either the
  start-tag of the element where the prefix is used or in an an
  ancestor element (i.e. an element in whose content the prefixed
  markup occurs). The prefix xml is by definition bound to the
  namespace name http://www.w3.org/XML/1998/namespace.

                    http://www.w3.org/TR/REC-xml-names/#nsc-NSDeclared
                                                         (my emphasis)

So MSV and the IBM quality checker should not complain about the fact
that the xml prefix has not been declared; they are buggy.

Unfortunately, the only work-around around their bugginess in XSLT is
to revert to disable-output-escaping to create the xs:schema element,
which is very ugly and might not even work (it depends on how you're
calling the transformation). There's no clean way to force the XSLT
processor to output a namespace declaration for the XML namespace.

What I recommend you do, therefore, is use your stylesheet as is, and
either write a custom serialiser to add a namespace declaration for
the XML namespace or do a bit of search-and-replace text processing on
the output of the transformation to add the namespace declaration. Oh,
and I recommend that you write bug reports to the MSV and SQC
developers.
                                                         
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread