• « What we all seem to have in common...
    • |
    • Main
    • |
    • It seems DaveP is all over the place today... »
            • November 29, 2004

              SGML to XML Converter

            • 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:

              • One from myself which is the typical canned answer for those looking to match multiple element case possiblities — in the match attribute of the template you want to catch all possible case usage for a particular element, separate each possible match with the union operator. Something like:
                   <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.

              • Another suggestion was to use the translate function within the match attribute to convert the case of each element before testing for a match. For example:
                   <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 :)

            • Posted by m.david : November 29, 2004 02:24 AM GMT

            Trackback Pings

            TrackBack URL for this entry:
            http://www.xsltblog.com/xslt-blog-mt/mt-tb.cgi/55

            Comments

            Post a comment




            Remember Me?

            (you may use HTML tags for style)

          • © 2005 :: <XSLT:Blog/> (xsltblog.com) is a product of M. David Peterson and FunctionalX Consulting. See Licensing Info Below.
          • Except where otherwise noted, this sites content and source code is licensed under the Attribution License from Creative Commons.