Unwanted namespace declarations in sqf/xsl output

Questions about XML that are not covered by the other forums should go here.
joewiz
Posts: 56
Joined: Fri Jun 06, 2008 8:05 pm

Unwanted namespace declarations in sqf/xsl output

Post by joewiz » 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:

Code: Select all

<item><hi rend="strong">S,</hi> Office of the Secretary</item>
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:

Code: Select all

<item><hi rend="strong"><term xml:id="t_S_1">S</term>,</hi> Office of the Secretary</item>
I couldn't figure out a single-pass fix using pure SQF for this, so I resorted to XSL:

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>
Unfortunately, the result of this for some reason adds an xmlns:xml namespace declaration to the result:

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>
When I split this SQF into two fixes, though, and add the attribute as a second fix, the xmlns:xml declaration is not there:

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>
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?

tavy
Posts: 177
Joined: Thu Jul 01, 2004 12:29 pm

Re: Unwanted namespace declarations in sqf/xsl output

Post by tavy » Mon Mar 20, 2017 6:55 pm

Hello,

Unfortunately I didn't found a solution for this problem.
It seems that the serializer that we use in oXygen when we create the fragment to be inserted, generates also the XML namespace declaration. I added an issue on our issue tracker. We will notify you when it will be fixed.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

tavy
Posts: 177
Joined: Thu Jul 01, 2004 12:29 pm

Re: Unwanted namespace declarations in sqf/xsl output

Post by tavy » Mon Oct 02, 2017 2:18 pm

Hello,

We released Oxygen XML Editor 19.1 a couple of days ago and the problem you reported should be fixed.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply