Custom XSL Stylesheets should use xsl:text to allow easier reading / editing

Bug #1945519 reported by Jason Boyer
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Confirmed
Wishlist
Unassigned

Bug Description

I have poked around in fm_IDL2js.xsl a little bit recently and have noticed that in order to reduce unwanted spaces in the resulting JSON many XSL elements have no whitespace or linebreaks between them. ThisishardtoreadandIdon'tcareforit.

This is necessary because of the way this stylesheet is built. If you use raw text as part of the stylesheet then spaces are kept since there's no way to distinguish the spaces you use to make your stylesheet easier to read vs those that are an important part of your data. Though whitespace between one XML element and another *are* removed, as is the SGML / XML / markup du jour custom.

So, were we to wrap all of our raw text output in fm_IDL2js.xsl* in <xsl:text></xsl:text> tags they can now be moved in, out, or shaken about and no extra spaces end up in the output. The stylesheet itself would also be much easier to read (at least insofar as xsl can, in fact, be made easy to read).

By way of a small example:

...
<xsl:value-of select="@id"/>:{name:"<xsl:value-of select="@id"/>",<xsl:if test="@reporter:label">label:"<xsl:value-of select="@reporter:label"/>"
...

and

...
        <xsl:value-of select="@id"/><xsl:text>:</xsl:text>
        <xsl:text>{name:"</xsl:text><xsl:value-of select="@id"/><xsl:text>",</xsl:text>
        <xsl:if test="@reporter:label">label:"<xsl:value-of select="@reporter:label"/>"
...

Both output the same text:
id:{name:"thing_id",label:"Thing Id"...

But you can tell that line 1 is the overall class definition, line 2 opens the new object and has the name key and value, and line 3 is the label key and value.

This would bloat the xsl file a little bit but I don't believe would be so much that there would be any adverse effects. I'll try to find some time to put together a branch.

*Or any other custom xsl files; I don't recommend we bother with those that are sourced from external locations like the MODS/MADS transforms.

Changed in evergreen:
status: New → Confirmed
tags: added: xml-xsl
tags: added: cleanup
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.