Re: [xsl] XML source with DOCTYPE declaration

Subject: Re: [xsl] XML source with DOCTYPE declaration
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Apr 2001 17:36:28 +0100
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="/">
      <!-- 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:apply-templates select="exsl:node-set($preprocessed)/*" />
      <!-- otherwise just apply templates -->
         <xsl:apply-templates />

<xsl:template match="*" mode="preprocess">
   <xsl:element name="{local-name()}"
      <xsl:copy-of select="@*"/>
      <!-- continue processing in 'preprocess' mode -->
      <xsl:apply-templates mode="preprocess" />

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

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:


rather than exsl:node-set()

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread