You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "rohit singh (JIRA)" <xa...@xml.apache.org> on 2008/12/02 16:04:44 UTC

[jira] Created: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Xpath support in Xalan does not work if default namespace is used
-----------------------------------------------------------------

                 Key: XALANJ-2469
                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects.  Anybody can view the issue.)
          Components: XPath
    Affects Versions: 2.0.x
         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
            Reporter: rohit singh
            Priority: Blocker
             Fix For: 2.0.x


We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 

"There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."

According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652797#action_12652797 ] 

Henry Zongaro commented on XALANJ-2469:
---------------------------------------

In my preceding analysis, I neglected to include a crucial reference to section 5.1 of XPath.[4]  That section states, "An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]."  It's the XML Namespaces recommendation that defines the concept of "expanded name", and there you'll find that the expanded name of a element node that has no prefix still has a namespace URI if there is a default namespace.  That's in contrast to section 2.3 of XPath, where the expanded name for a node test that is a QName that has no prefix has a null namespace URI.  That's the reason the node test does not match in this situation, despite the fact two QNames are syntactically identical.

[4] http://www.w3.org/TR/xpath#element-nodes

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "rohit singh (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653185#action_12653185 ] 

rohit singh commented on XALANJ-2469:
-------------------------------------

Hi Henry !!

This is what i tried. 

I used xpath expression as "/abc:Invoice" and defined the prefix abc as abc="http://edi.carquest.com/2007/types/transnet". The xml is same with default namespace as xmlns="http://edi.carquest.com/2007/types/transnet" in the root-tag. But this also did not help. 

We have already suggested about using /*[local-name()='Invoice']/*[local-name()='InvoiceHeader']/*[local-name()='InvoiceParty']  but this will be a performance hit when large XML files are processed.

I have also referred the RFC. Pulled out this section below, but not able to make much out of it :- 

"A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done for element type names in start and end-tags except that the default namespace declared with xmlns is not used: if the QName does not have a prefix, then the namespace URI is null (this is the same way attribute names are expanded). It is an error if the QName has a prefix for which there is no namespace declaration in the expression context."  




> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652451#action_12652451 ] 

Henry Zongaro commented on XALANJ-2469:
---------------------------------------

If you're using XSLT4J, your problem report should probably be directed to IBM.  However, the same problem might exist in Xalan-J, so I'll still follow up here.  I'm a bit confused by your comments:  you're evaluating /Invoice/InvoiceHeader/InvoiceParty and you say that it does return the specified elements.  Was that a typo?  Did you mean to say that it "does not return the specified element," or did you really mean that it "does return the specified elements," but you expected it to return an empty node set?

An empty node set should be the result in this case, as a NameTest in an XPath expression that has no prefix can only match a node that is in no namespace.  It cannot match nodes that are in the default namespace.

(There is some additional potential for confusion here, as the Xalan-J XPath API supports a namespace prefix resolver that will permit a NameTest that has no prefix to match nodes that were in the default namespace as supported by that prefix resolver - but that's not the usual mode of operation.)

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Resolved: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henry Zongaro resolved XALANJ-2469.
-----------------------------------

    Resolution: Invalid

Thanks for the clarification.  Note that this is an FAQ.[1]

Section 2.3 of the XPath recommendation[2] says, "A node test that is a QName is true if and only if the type of the node (see "5 Data Model") is the principal node type and has an expanded-name equal to the expanded-name specified by the QName."  Just above that appears the text you've quoted:  "if the QName does not have a prefix, then the namespace URI is null."  Section 5 of XPath[3] goes on to state, "Two expanded-names are equal if they have the same local part, and either both have a null namespace URI or both have non-null namespace URIs that are equal."

In your example, the node tests in /Invoice/InvoiceHeader/InvoiceParty have no prefix, so the namespace URIs in their expanped-names are null.  But the expanded-names of the corresponding nodes in your input document are not null, because they are in some non-null default namespace.  Hence, according to the definition of equality of expanded-names, the node tests in your path expression do not match the nodes in your input document, and an empty node set is the result of evaluating the path expression.

In order to resolve this problem, you'll need to specify some sort of prefix/namespace resolver (how you do so, depends on the API you're using) and use prefixes in your path expressions wherever you want to match nodes that are in a namespace.

If you really want to match nodes named Invoice, InvoiceHeader and InvoiceParty regardless of whether they are in a namespace or in no namespace (which isn't really considered good practice), you'll need to use a path expression like this:  /*[local-name()='Invoice']/*[local-name()='InvoiceHeader']/*[local-name()='InvoiceParty']

I hope that helps.

[1] http://xml.apache.org/xalan-j/faq.html#faq-N10207
[2] http://www.w3.org/TR/xpath#node-tests
[3] http://www.w3.org/TR/xpath#dt-expanded-name

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "rohit singh (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652405#action_12652405 ] 

rohit singh commented on XALANJ-2469:
-------------------------------------

The actual version of xalan use d by us is XSLT4J Java 2.7.4

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "rohit singh (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652455#action_12652455 ] 

rohit singh commented on XALANJ-2469:
-------------------------------------

sorry for typo. I meant "This xpath expression does NOT return the specified elements value."

What i expected is that i have a XML document which default namespace in the root-tag itself. Now when i pass the xpath "/Invoice/InvoiceHeader/InvoiceParty" then i expect Xalan to return the value of  element <InvoiceParty>. But that is not the case. If i got to xpath spec then it says it should work ir-respective of whether default namespace is present or not.

Now if i remove the default namespace from the root-tag then i get the expected result.

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2469) Xpath support in Xalan does not work if default namespace is used

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12662387#action_12662387 ] 

Henry Zongaro commented on XALANJ-2469:
---------------------------------------

Hi, Rohit.  Sorry for my delay in responding.  If you defined the prefix abc, an element node with a local name of Invoice should have been selected by /abc:Invoice, so long as it was in the same namespace specified by the prefix abc, regardless of the prefix actually used on the element node.

Do you have a complete sample test case that demonstrates what you described?

Thanks,

Henry

> Xpath support in Xalan does not work if default namespace is used
> -----------------------------------------------------------------
>
>                 Key: XALANJ-2469
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2469
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: XPath
>    Affects Versions: 2.0.x
>         Environment: Windows, IBM WebSphere Application Server - ND,  	6.1.0.7
>            Reporter: rohit singh
>            Priority: Blocker
>             Fix For: 2.0.x
>
>
> We are trying to use path for example "/Invoice/InvoiceHeader/InvoiceParty" as an X-Path expression. The XML document on which this xpath is evaluated has a default namespace defined. This xpath expression does return the specified elements value. I check the specification on xpath 1.0 on this url http://www.w3.org/TR/xpath and got this text below 
> "There is an element node for every element in the document. An element node has an expanded-name computed by expanding the QName of the element specified in the tag in accordance with the XML Namespaces Recommendation [XML Names]. The namespace URI of the element's expanded-name will be null if the QName has no prefix and there is no applicable default namespace."
> According to the above the xpath should work irrespective of whether we have specified a default namespace or not. Please take this as a high priority and fix this problem. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org