[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: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 06 Oct 2008 12:33:01 -0400
Re:  Namespace conflicts processing Word documents
Peter,

You might also consider making your shared module completely namespace-neutral, by using such tricks as

<xsl:template name="make-h1">
  <xsl:param name="contents">
    <xsl:apply-templates/>
  </xsl:param>
  <h1>
    <xsl:copy-of select="$contents"/>
  </h1>
</xsl:template>

... then calling the template by name from the namespace-specific stylesheets, instead of using a pattern match. (Other things can be parameterized too, including the context.)

So:

<xsl:template match="w:p[w:pPr[w:pStyle[@w:val='Heading1']]]">
  <xsl:call-template name="make-h1"/>
</xsl:template>

but also

<xsl:template match="w:p[w:pPr[w:pStyle[@w:val='Heading1']]]]" mode="special>
  <xsl:call-template name="make-h1">
    <xsl:with-param name="contents">
      <xsl:apply-templates mode="special"/>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

Mind you, I'd still rather pipeline. Basically the API you design amounts to mapping to a neutral language in any case, and what you gain in being able to compile for one pass is arguably lost in flexibility.

Cheers,
Wendell

At 11:52 AM 10/6/2008, you wrote:
Right, so I can have two otherwise identical stylesheets, one declaring the WordML w: namespace and the other declaring the OOXML w: namespace, with both using the identical
<xsl:template match="w:p[w:pPr[w:pStyle[@w:val='Heading1']]]">
<h1><xsl:apply-templates/></h1>
</xsl:template>
but I can't have a shell stylesheet for each namespace which both import/include the template code from a common (shared) file, because (a) namespaces don't get inherited into imports/includes, and (b) the common file will necessarily lack any namespace declaration for w: and will therefore not be well-formed.


OK. So long as I wasn't missing a trick there.

What I think you are missing is that an XSLT stylesheet has no obligation to use the same prefix as another XSLT stylesheet or any XML document being used as a source file.

Except that when it comes to process the document, the declared namespace URI (IRI) must be the same in both the stylesheet and the document.


I was hoping to do without preprocessing, but as this is all in Cocoon anyway, pipelining it isn't really a problem.

///Peter


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.