tracker issue : CF-3317598

select a category, or use search below
(searches all categories and all time range)
Title:

xmlsearch() not supporting xpath1.0 namespace alias

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Rob Sherman / Rob Sherman (CFDad)

Created: 08/24/2012

Components: Text Search

Versions: 10.0

Failure Type: Unspecified

Found In Build/Fixed In Build: Final /

Priority/Frequency: Trivial / All users will encounter

Locale/System: English / Mac 10 All

Vote Count: 0

Problem Description:
When you have an xml doc with a namespace the old xpath1.0 xmlsearch using xpath syntax "//:nodename" now throws an error.

Steps to Reproduce:

1. Sample xml:
<xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>123456789(hidden)</ID>
        <DisplayName>devPlayground</DisplayName>
    </Owner>
    <Buckets>
        <Bucket>
            <Name>myDevBucket</Name>
            2012-07-11T00:22:33.000Z
        </Bucket>
        <Bucket>
            <Name>myProdBucket</Name>
            2012-07-23T17:23:40.000Z
        </Bucket>
    </Buckets>
</ListAllMyBucketsResult>

2.  try an xmlsearch for buckets using this code:
local.buckets = xmlSearch(local.apiCall.response, "//:Bucket]");

3.  Throws an error about the colon - this used to work in CF9 (latest)


Actual Result:

Detail 	ColdFusion is unable to process the result of the XPath search. You may have an undefined variable in the xpath expression.
ErrNumber 	0
Message 	Unable to process the result of the XMLSearch for Unexpected colon at start of token.
StackTrace 	coldfusion.xml.XmlProcessor$XmlSearchException: Unable to process the result of the XMLSearch for Unexpected colon at start of token. at coldfusion.xml.XmlProcessor.doSearch(XmlProcessor.java:745) at coldfusion.xml.XmlProcessor.search(XmlProcessor.java:598) at coldfusion.runtime.CFPage.XmlSearch(CFPage.java:390) at coldfusion.runtime.CFPage.XmlSearch(CFPage.java:400) at 

Expected Result:

Expected to get an array of "Bucket" 

Any Workarounds:

Modify the xmlsearch as so:

local.buckets = xmlSearch(local.apiCall.response, "//*[local-name()='Bucket' and namespace-uri()='http://s3.amazonaws.com/doc/2006-03-01/']");

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3317598

External Customer Info:
External Company:  
External Customer Name: CFDad
External Customer Email:  
External Test Config: My Hardware and Environment details:



MacBook Pro 2010, 8gb Ram, ColdFusion 10 developer (stand alone) with Apache connector

Attachments:

Comments:

The code works in CF9 and breaks in CF10 . Bug verified
Comment by Suchika S.
18366 | January 06, 2014 03:14:37 AM GMT
The xpath expression here is not a valid one. Our previous library for xpath processing was lenient to such expressions so it used to work. The correct xpath to use here would be //Bucket and not to provide any namespace (as xmlns="http://s3.amazonaws.com/doc/2006-03-01/" has been used as default namespace without any prefix) (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
18367 | February 26, 2014 02:38:53 AM GMT