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

XML-to-XML recursive template handling

Subject: XML-to-XML recursive template handling
From: Lynn Murdock <lmurdock@xxxxxxxx>
Date: Thu, 8 Dec 2011 21:50:11 -0800
 XML-to-XML recursive template handling

I am doing an XML-to-XML transform in which I need to rearrange elements in
such a way that sometimes the context element is left empty when I am finished
rearranging (but not always). As a second step, I want to strip these newly
empty elements from the final output, and I am having trouble doing so.

For those of you who are familiar with the NLM's tool to convert older DTDs to
the 3.0 DTD, I am modifying the base.xsl component of the 2publishing3
conversion. Essentially, everything is copied through except elements that
need to be modified in one way or another. Specifically, I am moving certain
footnotes out of <fn-group> and into other locations in the document. If the
only footnotes in the original <fn-group> are those that I move, then after
this action, the result is <fn-group/>, which I want to remove from the final

I've tried several methods, and nothing I've tried is working. Any pointers
would be very much appreciated. I think that the issue is that I'm not fully
understanding how the recursion works here to re-process a node that I've
already processed once (or maybe it has to do with the default copy method for
the stylesheet?)...

(Default copy:
<xsl:template match="* | @* | text()" priority="-1">
<xsl:apply-templates select="@*|*|text()"/>

XSL version=1.0
Processor=Oxygen's built-in saxon (Oxygen version 11.2 for Linux)

Here's the relevant section of the stylesheet:

<xsl:template match="fn-group">
  <xsl:param name="node"><xsl:apply-templates/></xsl:param>
  <xsl:if test="fn">
    <xsl:for-each select="fn">
                       <!-- retag no fn-type to fn-type="other" -->
<xsl:when test="not(@fn-type)">
<fn fn-type="other">
<xsl:when test="@fn-type='other'">
<fn fn-type="other">
<!-- suppress here, moved to author-notes -->
<xsl:when test="fn-type='conflict'"/>
<!-- suppress here, retagged into funding-statement -->
<xsl:when test="fn-type='financial-disclosure'"/>
<xsl:call-template name="emptyfn">
<xsl:with-param name="node" select="$node"/>

<xsl:template name="emptyfn">
<xsl:param name="node"/>
<xsl:if test="not($node)"/>

Thanks much-


Lynn Murdock, MLIS
Web Producer
Public Library of Science (PLoS)

Lynn Murdock, MLIS
Web Producer
Public Library of Science (PLoS)

Current Thread


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