[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
Hi-

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
output.

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:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:template>)

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">
<fn-group>
    <xsl:for-each select="fn">
<xsl:choose>
                       <!-- retag no fn-type to fn-type="other" -->
<xsl:when test="not(@fn-type)">
<fn fn-type="other">
<xsl:apply-templates/>
</fn>
</xsl:when>
<xsl:when test="@fn-type='other'">
<fn fn-type="other">
<xsl:apply-templates/>
</fn>
</xsl:when>
<!-- 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:choose>
    </xsl:for-each>
</fn-group>
<xsl:call-template name="emptyfn">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
     </xsl:if>
</xsl:template>

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


Thanks much-

Lynn



Lynn Murdock, MLIS
Web Producer
Public Library of Science (PLoS)
http://www.plos.org<http://www.plos.org/>




Lynn Murdock, MLIS
Web Producer
Public Library of Science (PLoS)
http://www.plos.org

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.