Unwanted namespace declarations in sqf/xsl output
Posted: Fri Mar 17, 2017 7:31 pm
Hi all,
I've just been experimenting using Schematron Quick Fixes on my TEI documents. My goal is to catch cases like this:
And offer to (1) wrap "S" in a TEI <term> element and (2) to generate a unique ID for this new element and insert an @xml:id attribute on the <term> element, with the following result:
I couldn't figure out a single-pass fix using pure SQF for this, so I resorted to XSL:
Unfortunately, the result of this for some reason adds an xmlns:xml namespace declaration to the result:
When I split this SQF into two fixes, though, and add the attribute as a second fix, the xmlns:xml declaration is not there:
Is there a better way that allows me to (1) perform the fix in a single step and (2) prevent the unwanted xmlns namespace declaration?
I've just been experimenting using Schematron Quick Fixes on my TEI documents. My goal is to catch cases like this:
Code: Select all
<item><hi rend="strong">S,</hi> Office of the Secretary</item>
Code: Select all
<item><hi rend="strong"><term xml:id="t_S_1">S</term>,</hi> Office of the Secretary</item>
Code: Select all
<let name="term" value="if (ends-with(.//tei:hi[1], ',')) then replace(.//tei:hi[1], ',$', '') else .//tei:hi[1]"/>
<let name="id" value="concat('t_', replace($term, '\W', ''), '_1')"/>
<sqf:fix id="add-term-and-xml-id">
<sqf:description>
<sqf:title>Add a missing term element</sqf:title>
</sqf:description>
<sqf:replace match="tei:hi[1]">
<xsl:element name="tei:hi">
<xsl:attribute name="rend" select="./@rend"/>
<xsl:element name="tei:term">
<xsl:attribute name="xml:id" select="$id"/>
<xsl:value-of select="$term"/>
</xsl:element>
<xsl:text>,</xsl:text>
</xsl:element>
</sqf:replace>
</sqf:fix>
Code: Select all
<item><hi rend="strong"><term xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:id="t_S_1">S</term>,</hi> Office of the Secretary</item>
Code: Select all
<sqf:fix id="add-xml-id">
<sqf:description>
<sqf:title>Add a missing @xml:id</sqf:title>
</sqf:description>
<sqf:add match=".//tei:term" target="xml:id" node-type="attribute" select="$id"/>
</sqf:fix>