[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Namespace conflicts processing Word documents

Subject: RE: Namespace conflicts processing Word documents
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 6 Oct 2008 14:28:11 +0100
RE:  Namespace conflicts processing Word documents
> WordML and OOXML files (Word saved-as-XML from vv2003-2008) 
> contain some different namespace declarations for the same 
> prefix (specifically w: but a few others).
> On the surface, this appears to mean that an XSLT file 
> written to process WordML files' w:* elements cannot be used 
> to process OOXML files' w:* elements 

Depends exactly what you mean. Of course you can process both namespaces,
because there is no requirement for the stylesheet to use the same prefix as
the source document: it can use any prefix it likes, so long as it is bound
to the correct URI. However, it's always challenging to write reusable
stylesheet code that can process two different (but similar) vocabularies
that use different namespace URIs (this has nothing to do with whether or
not they use the same prefix).

The way I usually recommend doing it is to preprocess the input to change
its namespace, so that the bulk of your transformation code only has a
single namespace to contend with: that is, use a pipeline.

> I tested this by creating two "driver" XSLT files, one 
> implementing the WordML namespace declarations and one the 
> OOXML ones; with both files having a single xsl:import or 
> xsl:include (tested both ways) calling my file of templates 
> which itself declared no namespaces except XSL.
> Both Saxon and xalan throw an error, saying that the 
> namespace w: was undeclared in all cases.
> This makes it appear that namespaces cannot be inherited from 
> an outer XSLT file to an included or imported one; in effect 
> that the omission of namespace declarations on the 
> included/imported xsl:stylesheet element nullifies all outer 
> namespace declarations.
> Is this correct, or have I missed something?

It's certainly true that an included or imported stylesheet module doesn't
inherit any namespace declarations from the including/importing module.

Michael Kay

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.