Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope of namespace declarations and XPath expressions defective #116

Closed
jperterm opened this issue Jan 10, 2023 · 4 comments
Closed

Scope of namespace declarations and XPath expressions defective #116

jperterm opened this issue Jan 10, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@jperterm
Copy link

I discovered two issues with namespace declaration scopes and XPath expressions.

First thing is a missing error, that a namespace is undeclared:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="#all"
                version="3.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:mode on-no-match="shallow-copy"/>
    <xsl:template match="/*" mode="#all">
        <out>
            <xsl:value-of xmlns:ns1="urn:namespace1" select="@ns1:attr"/>
            <xsl:value-of select="@ns1:attr"/><!-- Missing error caused by line above -->
        </out>
    </xsl:template>
</xsl:stylesheet>

The second thing is an error that must not occur:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="#all"
                version="3.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:mode on-no-match="shallow-copy"/>
    <xsl:template match="/*" mode="#all">
        <out>
            <!-- False error caused by namespace declaration **following up** the select attribute -->
            <xsl:value-of select="@ns1:attr" xmlns:ns1="urn:namespace1"/>
        </out>
    </xsl:template>
</xsl:stylesheet>
@pgfearo pgfearo added the bug Something isn't working label Jan 10, 2023
@pgfearo
Copy link
Member

pgfearo commented Jan 12, 2023

Even though related I will treat these 2 bugs as separate:

bug (1) (missing error) is caused by the primitive way in which in-scope namespaces are tracked - the solution is fairly trivial - I will tackle this next

bug (2) (false error because xmlns occurs after select attribute) is fixed and awaiting next release. To fix this, when an xmlns declaration is encountered, any 'prefix problems' for the declared prefix that are on the same element as the xmlns declaration are removed.

@pgfearo
Copy link
Member

pgfearo commented Jan 12, 2023

For bug(2) there was a related problem when xmlns declarations occurred after a name attribute with a prefixed value, e.g.

<xsl:function name="fn:test" xmlns:fn="com.deltaxml">

This issue is also fixed by removing the problem when the matching xmlns on the same element is found.

@pgfearo
Copy link
Member

pgfearo commented Jan 13, 2023

Fix for bug(1) (missing error) now also fixed on the github repo - bug(1) and bug(2) fixes now awaiting release.

this occurred when any preceding sibling element had an xmlns declaration with that prefix. The preceding sibling erroneously passing on namespace scope could be an element with start/end tags or a self-closed element.

@pgfearo
Copy link
Member

pgfearo commented Jan 13, 2023

Namespace scoping bugs fixed in Release 1.4.3

@pgfearo pgfearo closed this as completed Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants