DesignLiquido / xslt-processor

A JavaScript XSLT processor without native library dependencies
GNU Lesser General Public License v3.0
95 stars 30 forks source link

Input namespace not used #47

Closed drstil closed 11 months ago

drstil commented 3 years ago

Thank you for creating and sharing this great library! 😃

I have a lot of already programmed xsl-scripts, which use namespaces like this. They could be successfully processed with xsltproc, but not with this processor, see the following example:

Input string:

<?xml version="1.0" encoding="ISO-8859-1"?>
<ClinicalDocument xmlns="http://testnamespace">
    <test name="test1" />
    <test name="test2" />
    <test name="test3" />
    <test name="test5" />
</ClinicalDocument>

With the following xsl-script, I got the excepted output with xsltproc:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n="http://testnamespace">
    <xsl:template match="/">
        <xsl:copy-of select="n:ClinicalDocument/n:test" />
    </xsl:template>
</xsl:stylesheet>

Output:

<?xml version="1.0"?>
<test xmlns="http://testnamespace" name="test1"/><test xmlns="http://testnamespace" name="test2"/><test xmlns="http://testnamespace" name="test3"/><test xmlns="http://testnamespace" name="test5"/>

But with the xslt-processor it only works like this (so only without namespace):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n="http://testnamespace">
    <xsl:template match="/">
        <xsl:copy-of select="ClinicalDocument/test" />
    </xsl:template>
</xsl:stylesheet>

How could I apply the namespace correctly so that I do not have to change all xsl-scripts?

Would be nice to get some reply!

Thank you and best!