Subject: [xsl] XML-to-XML recursive template handling From: Lynn Murdock <lmurdock@xxxxxxxx> Date: Thu, 8 Dec 2011 21:50:11 -0800 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping paragraphs and s, Martin Honnen | Thread | Re: [xsl] XML-to-XML recursive temp, Wendell Piez |
Re: [xsl] Dealing mixed content wit, David Carlisle | Date | [xsl] mode question, Roelof Wobben |
Month |