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

Re: XML source with DOCTYPE declaration

Subject: Re: XML source with DOCTYPE declaration
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Apr 2001 17:36:28 +0100
xsl template mode preprocess
Hi Zeljko,

> So what am I doing wrong? Or did I maybe misunderstand you and I
> have to do the complete transformation in 2 separate steps:
>
> 1. Doing the preprocessing and save the output temporary
> 2. Using this temporary ouput (file) as source for the intended
> transformation

Yes - that's what I meant - two separate processes.  You *could* do it
in the same stylesheet, if you're prepared to use a node-set()
extension function.  So you could have a stylesheet like:

<xsl:template match="/">
   <xsl:choose>
      <!-- when the html document element isn't in the XHTML
           namespace -->
      <xsl:when test="not(html:html)">
         <!-- apply templates in preprocess mode to get the namespaced
              input -->
         <xsl:variable name="preprocessed">
            <xsl:apply-templates mode="preprocess" />
         </xsl:variable>
         <xsl:apply-templates select="exsl:node-set($preprocessed)/*" />
      </xsl:when>
      <!-- otherwise just apply templates -->
      <xsl:otherwise>
         <xsl:apply-templates />
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

<xsl:template match="*" mode="preprocess">
   <xsl:element name="{local-name()}"
                namespace="http://www.w3.org/1999/xhtml">
      <xsl:copy-of select="@*"/>
      <!-- continue processing in 'preprocess' mode -->
      <xsl:apply-templates mode="preprocess" />
   </xsl:element>
</xsl:template>

<xsl:template match="html:html">
   <xsl:text>html element found !!!</xsl:text>
   <xsl:apply-templates/>
</xsl:template>
        
<xsl:template match="html:body">
   <xsl:text>body element found !!!</xsl:text>
   <xsl:apply-templates/>
</xsl:template>

Note that the namespace you use for the node-set() extension function
in the root-node-matching template is determined by the processor that
you're using. For example, using Xalan then you actually need:

  lxslt:nodeset()

rather than exsl:node-set()

I hope that helps,

Jeni

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



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


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.