Subject: Re: [xsl] Group and change heading element From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 Sep 2018 17:55:12 -0000 |
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>
<xsl:for-each-group select="*" group-starting-with="h1"> <sec> <xsl:apply-templates select="current-group()"/> </sec> </xsl:for-each-group>
<xsl:template match="h1"> <title> <xsl:apply-templates/> </title> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Group and change heading elem, Charles O'Connor coc | Thread | Re: [xsl] Group and change heading , Graydon graydon@xxxx |
[xsl] Group and change heading elem, Charles O'Connor coc | Date | Re: [xsl] Group and change heading , Graydon graydon@xxxx |
Month |