4 users online. Create an account or sign in to join them.Users
Headline Hierarchy
This is an open discussion with 12 replies, filed under XSLT.
Search
Ah, great utility!
I am not sure but are you certain about the match="body//@*"? Does one have to hardcode their Xpath in your utility in order to use it?
Thanks, phoque. That’s a copy and paste mistake.
Alright :-)
Hm, maybe a special mode could help the user to know when he’s actually calling the ninjas to work. What do you think?
I thought about that but wanted to keep things similar to Allen’s tutorial. I often use a mode for the Ninja technique called typographic as I like to change more things than just headlines. It would also be possible to set the hierarchy via with-param.
Headline Hierarchy updated to version 1.1 on 7th of May 2010
This wasn't handling ID attributes on my headings. I noticed that ''mode="ninja"'' isn't applied to the template call for attributes (on line 47 or thereabouts) and that adding this fixes the problem for me.
<!-- Change hierarchy -->
<xsl:element name="h{substring-after(name(), 'h') + $level}">
<xsl:apply-templates select="* | @* | text()" mode="ninja" />
</xsl:element>
Heisann,
if have a usage-issue with this, guess it’s a simple mistake …
I have a formatted text, when I reference it like this, the headline-hierarchy is not applied:
<xsl:apply-templates select="text/*" mode="ninja" />
If I use the following, it is applied, but remains enveloped by the <text mode="formatted"> xml element:
<xsl:apply-templates select="text" mode="ninja" />
What's inside your text node?
The formatted text is simply a set of paragraphs and headlines:
<p>…</p> <h2>…</h2> <p>…</p> <p>…</p>
I guess this is a plain selector problem, but how can i tackle it? :(
This might be overkill, but here's how I apply the utility to a node called <content>. In the main data template, I call:
<xsl:apply-templates select=".//content" mode="formatted"/>
And that calls this template:
<xsl:template match="//content" mode="formatted">
<xsl:apply-templates select="*" mode="ninja">
<xsl:with-param name="level" select="1"/>
</xsl:apply-templates>
</xsl:template>
@tachyondecay brill! this works like a charm, thanks a 1000!
Create an account or sign in to comment.
A new XSLT utility, “Headline Hierarchy” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.