Subject: Re: [xsl] Detecting XML elements not transformed From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx> Date: Tue, 22 Apr 2008 15:25:32 +0200 |
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.
<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: Dokumentations-Technologie Adobe Certified Expert, FrameMaker Lvsungen und Training, FrameScript, XML/XSL, Unicode <http://cap-studio.de/> -- Tel. +49 (9131) 28747
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Detecting XML elements no, Harry Liljeström | Thread | [xsl] retain/rebuild unparsed entit, Graswinckel_Ewout |
RE: [xsl] retain/rebuild unparsed e, Michael Kay | Date | [xsl] XSL-T should naturally loop? , Dan Acuff |
Month |