|
Subject: [xsl] Group and change heading element From: "Charles O'Connor coconnor@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 Sep 2018 17:49:17 -0000 |
Hi all,
Using XSLT 2.0, Saxon PE 9.7.0.15 in Oxygen 19
I am attempting to wrap headings and paragraphs into <sec> elements while
changing the <h1> to <title>. So, given this XML
<root>
<body><div class="abstract">
<h1><b>Bold</b> Intro!</h1>
<p>This is an intro <i>with <b>various</b> formatting</i> and other
stuff.</p>
<p>This is a second para in the intro</p>
<h1>Methods</h1>
<p>There is no method to our madness</p>
<h1>Results</h1>
<p>The results are soooo good . . . </p>
<p> . . . they require . . . </p>
<p> . . . three paragraphs</p>
<h1>Conclusion</h1>
<p>This is all that is necessary</p>
</div></body>
</root>
I want:
<root>
<body>
<abstract>
<sec>
<title><bold>Bold</bold> Intro!</title>
<p>This is an intro <italic>with <bold>various</bold>
formatting</italic> and other
stuff.</p>
<p>This is a second para in the intro</p>
</sec>
<sec>
<title>Methods</title>
<p>There is no method to our madness</p>
</sec>
<sec>
<title>Results</title>
<p>The results are soooo good . . . </p>
<p> . . . they require . . . </p>
<p> . . . three paragraphs</p>
</sec>
<sec>
<title>Conclusion</title>
<p>This is all that is necessary</p>
</sec>
</abstract>
</body>
</root>
But with this template:
<xsl:template match="div">
<abstract>
<xsl:for-each-group select="*" group-starting-with="h1">
<sec>
<title>
<!--<xsl:value-of select="."/>-->
<xsl:apply-templates/>
</title>
<xsl:for-each select="current-group()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:for-each>
</sec>
</xsl:for-each-group>
</abstract>
</xsl:template>
I get
<root>
<body>
<abstract>
<sec>
<title><bold>Bold</bold> Intro!</title>
<h1><bold>Bold</bold> Intro!</h1>
<p>This is an intro <italic>with <bold>various</bold>
formatting</italic> and other
stuff.</p>
<p>This is a second para in the intro</p>
</sec>
<sec>
<title>Methods</title>
<h1>Methods</h1>
<p>There is no method to our madness</p>
</sec>
<sec>
<title>Results</title>
<h1>Results</h1>
<p>The results are soooo good . . . </p>
<p> . . . they require . . . </p>
<p> . . . three paragraphs</p>
</sec>
<sec>
<title>Conclusion</title>
<h1>Conclusion</h1>
<p>This is all that is necessary</p>
</sec>
</abstract>
</body>
</root>
That is, the <h1> element is retained. I've tried various ways of excluding it
from the results, but the best I've done gets rid of the element but retains
the text.
Thanks for your help!
-Charles
Charles O'Connor l Business Analyst
Aries Systems Corporation l www.ariessys.com
50 High Street, Suite 21 l North Andover, MA l 01845 l USA
Direct: 802-585-5655 Main: 978-975-7570 l Help Desk: 978-291-1966 | Fax:
978-975-3811
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] problem: getting link tex, Trevor Nicholls trev | Thread | Re: [xsl] Group and change heading , Martin Honnen martin |
| Re: [xsl] problem: getting link tex, Trevor Nicholls trev | Date | Re: [xsl] Group and change heading , Martin Honnen martin |
| Month |