On Thu, Jan 04, 2018 at 05:46:53PM -0000, Charles O'Connor
coconnor(_at_)ariessys(_dot_)com scripsit:
How do I exclude them? A bonus would be to know how to preserve the
punctuation and spaces between the <string-name> (and <collab> and
<etal>) elements.
Well, you don't really have a good use case for the identity template
here; you'd be trying to distinguish text elements by relative position.
It looks like what you've got is a grouping problem; you want to get rid
of the label element, group up everything before a certain element, and
have everything else stay the same.
If the example displays a consistent pattern -- you want everything in
front of the article-title to wind up in the person-group --
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:variable as="element(ref)" name="example">
<ref id="r2">
<label>2.</label>
<mixed-citation publication-type="journal"><string-name
name-style="western"><surname>Selvarajah</surname>
<given-names>S</given-names></string-name>, <string-name
name-style="western"><surname>Hammond</surname>
<given-names>ER</given-names></string-name>, <string-name
name-style="western"><surname>Haider</surname>
<given-names>AH</given-names></string-name>, <string-name
name-style="western"><surname>Abularrage</surname>
<given-names>CJ</given-names></string-name>, <string-name
name-style="western"><surname>Becker</surname>
<given-names>D</given-names></string-name>, <string-name
name-style="western"><surname>Dhiman</surname>
<given-names>N</given-names></string-name>, <etal>et
al.</etal>
<article-title>The burden of acute traumatic spinal cord injury
among adults in the United States: an update.</article-title>
<source>J Neurotrauma</source>
<year>2014</year>;<volume>31</volume>(<issue>3</issue>):<fpage>228</fpage>-<lpage>38</lpage>.</mixed-citation>
</ref>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="$example"/>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="label">
<!-- drop this element -->
</xsl:template>
<xsl:template match="mixed-citation">
<xsl:copy>
<xsl:copy-of select="@*"/>
<person-group>
<xsl:sequence
select="node()[following-sibling::article-title]"/>
</person-group>
<xsl:sequence select="node()[self::article-title or
preceding-sibling::article-title]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
gives me
<ref id="r2">
<mixed-citation publication-type="journal"><person-group><string-name
name-style="western"><surname>Selvarajah</surname><given-names>S</given-names></string-name>,
<string-name
name-style="western"><surname>Hammond</surname><given-names>ER</given-names></string-name>,
<string-name name-style="western"
<surname>Haider</surname><given-names>AH</given-names></string-name>,
<string-name name-style="western"
<surname>Abularrage</surname><given-names>CJ</given-names></string-name>,
<string-name name-style="western"
<surname>Becker</surname><given-names>D</given-names></string-name>,
<string-name name-style="western"
<surname>Dhiman</surname><given-names>N</given-names></string-name>, <etal>et
al.</etal></person-group><article-title>The burden of acute traumatic
spinal cord injury among adults in the United States: an
update.</article-title><source>J
Neurotrauma</source><year>2014</year>;<volume>31</volume>(<issue>3</issue>):<fpage>228</fpage>-<lpage>38</lpage>.</mixed-citation>
</ref>
If you need to do other processing the "xsl:sequence" can be
"xsl:apply-templates".
-- Graydon
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--