• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

BUG? ORDINAL as XMLAttribute inside CFLOOP

New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

I have parsed an XML string into an XML document. I'm converting it into a query for future operations.
I loop through the xmlNodes I'm interested in and all works fine except when I'm trying to retrieve an XMLAttribute on a specific XMLChild.
----------snip---------------
<CFSET var recCnt = ArrayLen(NodeSet) />
<CFLOOP index="r" from="1" to="#recCnt#">
<CFSET bAdd = QueryAddRow(THIS.qry)>
<CFSET tmp = QuerySetCell(THIS.qry, "AID", NodeSet.XmlAttributes.ID) />
<CFSET tmp = QuerySetCell(THIS.qry, "article_title", NodeSet.HEADLINE.XmlText) />
<CFSET tmp = QuerySetCell(THIS.qry, "article_abstract", NodeSet.ABSTRACT.XmlText) />
<CFSET tmp = QuerySetCell(THIS.qry, "article_section_id", NodeSet.SECTION.XmlAttributes.ID) />
<CFSET tmp = QuerySetCell(THIS.qry, "article_parent", NodeSet.XmlAttributes.PARENT) />
<CFSET tmp = QuerySetCell(THIS.qry, "pub_name", NodeSet.PUBLICATION.XmlText) />
<CFSET tmp = QuerySetCell(THIS.qry, "publish_dt", NodeSet.XmlAttributes.PUBLISHDATE) />
<CFIF StructKeyExists(NodeSet.XmlAttributes,"TOPSTORY")>
<CFSET tmp = QuerySetCell(THIS.qry, "TSOrdinal", NodeSet.XmlAttributes.TOPSTORY) />
<CFELSE>
<CFSET tmp = QuerySetCell(THIS.qry, "TSOrdinal", 0) />
</CFIF>
<CFSET tmp = QuerySetCell(THIS.qry, "StoryOrder", NodeSet.SECTION.XmlAttributes.ORDINAL) />
</CFLOOP>
----------snip-------------
Note that
<CFSET tmp = QuerySetCell(THIS.qry, "article_section_id", NodeSet.SECTION.XmlAttributes.ID) />
works fine, but
<CFSET tmp = QuerySetCell(THIS.qry, "StoryOrder", NodeSet.SECTION.XmlAttributes.ORDINAL) />
generates an error:
"Element SECTION.XMLATTRIBUTES.ORDINAL is undefined in a Java object of type class coldfusion.xml.XmlNodeMap referenced as"

When I CFDUMP the NodeSet.SECTION.XmlAttributes I see both the ID and the ORDINAL plain as day but when I try to reference the ORDINAL its never defined.
I've tried DUPLICATEing the structure into a new variable and referincing.
<CFSET AttCpy = Duplicate(NodeSet.SECTION.XmlAttributes) />
<CFSET tmp = QuerySetCell(THIS.qry, "StoryOrder", AttCpy.ORDINAL) />
Still undefined.
I've tried looking at an array of keys from StructKeyArray. If I CFDUMP the array; ORDINAL is visible - when I try to reference the Array's position for the key, it's undefined.

At my wits end. Any advice? Have a found a bug?
TOPICS
Advanced techniques

Views

423

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Dec 20, 2006 Dec 20, 2006
There are SECTIONS that do not have an ORDINAL attribute.
Article Parent ID's: 1655419, 1655516, etc.

You need to check that an attribute (and also a node) exists before grabbing its value.

Never trust XML that you didn't write yourself!

Votes

Translate

Translate
Advisor ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

XmlAttributes works with any syntactically valid attribute.

It's difficult to see the problem in the code here without also seeing the data.

Do a <CFDUMP var="#NodeSet#"> and post a link to a page showing the results or "Attach Code" the results here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

MikerRoo:
Thanks for taking a peak at this. XmlAttributes seems to be working everywhere except on the ORDINAL attribute of SESSION.

http://lonebuffalo.com/Nodes.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

There are SECTIONS that do not have an ORDINAL attribute.
Article Parent ID's: 1655419, 1655516, etc.

You need to check that an attribute (and also a node) exists before grabbing its value.

Never trust XML that you didn't write yourself!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

LATEST
DOH! Thanks for the second set of eyes!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation