In a recent post to XSL-List the ever insightful Dave Pawson responded to a question in regards to case conversion of element and attribute names. A combination of suggestions were originally presented including:
<xsl:template match="foo | Foo">
...process
</xsl:template>
While this is a solution that works well for a manageable (read: limited) number of possibilites it doesn’t scale — in other words it doesn’t take long before this solution becomes more of a code management nightmare and a performance bottleneck for the processor.
<xsl:template match="*[translate(name(), 'ABC..', 'abc..') = 'italic']">
<!-- Yuck... -->
</xsl:template>
I think the authors (Geerst Josten) comment that exists where the typical “processing code goes here…” speak for itself. While I haven’t tested this particular idea it seems like it could logically work… but the yuck comes when you are running a translate function on every node that falls through the template base looking for a home… something Geerst was obviously aware of.
I guess DaveP took pity on both the questioner and the not-so-helpful solutions Geerst and I offered up as he brought out something I did’nt even know existed until now….
That DaveP always has a trick or two up his sleeve (either that or I need to spend some quality time with the FAQ again… hmmm…)
http://www.jclark.com/sp/sx.htm
Inserted Comment[MDP]: This text comes from the SX site.
“SX converts SGML to XML. SX parses and validates the SGML document contained in sysid… and writes an equivalent XML document to the standard output. SX will warn about SGML constructs which have no XML equivalent.
-x xmloutputoption
lower Prefer lower case. Names that were subjected to upper-case substitution by SGML will be folded to lower case. This does not include reserved names; XML requires these to be in upper-case.”
so sx -x lower will do the translation you want, producing lower case tags.
HTH DaveP
As always Dave, it does :)
TrackBack URL for this entry:
http://www.xsltblog.com/xslt-blog-mt/mt-tb.cgi/55