So, it looks like XmlSearch has not implemented searches on attribute
values, as in the examples I've given below.  Is that a safe assumption?


If this is true, then is there any way we can get direct access to the DOM
parser in MX, and write our own functions against it?



-----Original Message-----
From: James Alexander [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 12, 2003 8:32 AM
To: CF-Talk
Subject: RE: XPath in CFMX


MX uses a DOM parser. SAX parsers by their very nature are event driven,
and well, CF isn't an event driven language. There is however a handful
of Java SAX parsers available that could potential be used, but I
wouldn't recommend using one in CF.

- James

-----Original Message-----
From: Joe Eugene [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 11, 2003 11:13 PM
To: CF-Talk

Ben,
The only difference is see from plain XPath, is using
(XmlChildren,XmlText,XmlAttributes).

Example
<?xml version="1.0" encoding="UTF-8"?>
<Books>
  <Book type="Reference Book">
    <Title>Java Programming</Title>
    <Author>Ivor Horton</Author>
  </Book>
</Books>
<cfset odoc=xmlParse(books)>
<cfoutput>
#odoc.Books.Book[1].Title.XmlText#
#odoc.Books.Book[1].XmlAttributes["type"]#
</cfoutput>

Here the only thing different from XPath specs, is using "odoc" and
"XmlText|XmlAttributes".

<cfset xRes=xmlSearch(odoc, "/Books/[EMAIL PROTECTED]'Reference Book']")>
This also works exactly like XPath Specifications.

I havent used MSXML. I think CFMX uses Xerces/Crimson/Sax parsers which
should in
line with W3C XML/XPath specifications. I am curious on cfmx
implementations
of SAX and DOM Parsing, Which one does CFMX Use...

Joe Eugene


> -----Original Message-----
> From: Mueller, Ben [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 11, 2003 9:26 PM
> To: CF-Talk
> Subject: XPath in CFMX
>
>
> My company is in the process of moving over to MX, and I have been
tasked
> with upgrading our XML handling custom tags to MX compliance.  I have
> discovered what appears to be a bug in the way MX handles Xpath, and
if it
> isn't a bug, then it's a deviation away from the standard
> implementation of
> Xpath, and if it isn't THAT, then it's a failure in my understanding.
>
> We are currently running CF 5 (development) and 4.5.2
> (production), and both
> use MS XML 4.0 for XML handling.
>
> We have quite a bit of code which, using Xpath, gets the value of an
> attribute.  The code typically looks something like this:
>
> <cf_readXMLnode node=#myNode# xpath="./subnode/@name">
>
> In our current environment, this returns the value of the "name"
attribute
> in the subelement called "subnode".
>
> When I tried to get this same code to work in MX (essentially by
changing
> the guts of cf_readXMLnode), I got an array of length 1, where
> the 1 item in
> the array is empty.
>
> What I can't tell at this point is whether:
> a) the MS XML parser deviated from the Xpath spec, and in fact a call
like
> "./subnode/@name" is invalid, so CFMX doesn't support it
> b) CFMX deliberately doesn't support these type of Xpath calls for
some
> reason
> c) This is a bug in CFMX
> d) There's something I'm missing about how MX handles XML
>
> I understand the way MX wants me to access element attributes
> (#node[x].xmlattributes["name"]#), but I would really like to avoid
using
> this method, because it would involve changing a ton of Xpath
> statements and
> code logic, rather than just a few custom tags.  I'm also rather
> miffed that
> I can take advantage of the full Xpath spec.
>
> Any help/advice would be appreciated.  If I haven't stated the problem
> clearly enough, please tell me where it's fuzzy and I'll try to
sharpen it
> up.
>
> Thanks,
> Ben
>
> I've included some sample MX code below to illustrate the problem:
>
> <cfxml variable="sampleXML">
>     <rule name="firstRule">
>         <subelement name="myAttribute">text here</subelement>
>     </rule>
> </cfxml>
>
>
> <!--- This works: --->
> <cfoutput>#sampleXML["rule"].xmlattributes["name"]#</cfoutput>
>
> <!--- This returns an array with one position that is empty: --->
> <cfset res1 = xmlSearch(sampleXML,"rule/@name")>
> <cfdump var=#res1#>
>
>
> <!--- The same holds true if I try and get the value of the
> attribute on the
> subelement --->
>
> <!--- This works: --->
> <cfset res2 = xmlSearch(sampleXML,"./rule/subelement")>
> <cfoutput>#res2[1].xmlattributes["name"]#</cfoutput>
>
> <!--- This returns an array with one position that is empty: --->
> <cfset res3 = xmlSearch(sampleXML,"./rule/subelement/@name")>
> <cfdump var=#res3#>
> 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to