xsl-list
[Top] [All Lists]

Re: [xsl] Detecting XML elements not transformed

2008-04-22 06:26:06
Am 22.04.2008 um 11:45 schrieb Harry Liljeström:

Thanks Michael for responding my question so quickly.

The unsupported.xml could have following XML structure:

<unsupported>
   <!--... ALL UNSUPPORTED NODES LISTED HERE ...-->
<node name="name_of_unsupported_node" xpath="xpath_to_unsupported_node"/>
</unsupported>

The main idea here is, that when the application reads the upgraded 4.x configuration and it shows an information dialog were it displays those unsupported 3.x XML elements.

It seems you want something like

<xsl:result-document href="unsupported.xml">
  <unsupported>
    <xsl:for-each select="//all_unsupported_nodes">
      ...
    </xsl:for-each>
  </unsupported>
</xsl:result-document>

Michael Kay's answer tells me it is not that easy and you may need a two-step process:

1) mark all unsupported nodes and process all supported nodes as desired using Michael example:

<xsl:template match="*">
  <xxx:untransformed-element>
    <xsl:copy-of select="."/>
    (or perhaps <xsl:apply-templates/>)
  </xxx:untransformed-element>
</xsl:template>


2) take this intermediate XML and filter all marked nodes to unsupported.xml

<xsl:template match="/">
  <!-- create a file with the unsupported nodes -->
  <xsl:result-document href="unsupported.xml">
    <unsupported>
      <xsl:for-each select="//xxx:untransformed-element">
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </unsupported>
  </xsl:result-document>
  <!-- pass through all but the above elements -->
<xsl:apply-templates select="node()[name()!='xxx:untransformed- element']" />
</xsl:template>

<!-- identity transform does the rest -->
<xsl:template match="element()">
  <xsl:copy>
    <xsl:apply-templates select="@*,node()"/>
   </xsl:copy>
</xsl:template>

<xsl:template match="attribute()|text()|comment()|processing- instruction()">
  <xsl:copy/>
</xsl:template>


By the way, what do you mean with "identity transform template"?

See <http://ajwelch.blogspot.com/2008/01/indentity-transform-for- xslt-20.html> and the XSLT FAQ by Dave Pawson.

- Michael Müller-Hillebrand

--
_______________________________________________________________
Michael Müller-Hillebrand: Dokumentations-Technologie
Adobe Certified Expert, FrameMaker
Lösungen und Training, FrameScript, XML/XSL, Unicode
<http://cap-studio.de/> -- Tel. +49 (9131) 28747




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>