RE: Getting Namespaces into a Transform

> 
> Hope this isn't too off-topic, but I want to insert a schema reference
> in an XSLT transform.  I need for XML document A to transform to
> document B, and I need the following namespace attributes in the root
> node:
> 
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="NewPPSSchema.xsd" .......>
> 

If you put exactly that in your stylesheet, then you should get exactly that
in your result tree.

It's possible that the XML parser will interpret the
xsi:noNamespaceSchemaLocation attribute as an instruction to validate the
stylesheet against the schema at that location. You should be able to switch
off that interpretation in the parser API, but if you can't, then it may be
safer to generate the attribute using xsl:attribute, or to use a namespace
alias:

<root xmlns:xsia="dummy"
  xsia:noNamespaceSchemaLocation="NewPPSSchema.xsd" .......>

<xsl:namespace-alias stylesheet-prefix="xsia" result-prefix="xsi"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

You didn't actually say what you attempted and how it is failing.

Michael Kay

Received on Tuesday, 16 November 2004 00:57:10 UTC