Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incomprehensible - for me - Ebay XML grammatical error 1

Status
Not open for further replies.

SBonfiglio

IS-IT--Management
Sep 15, 2008
24
IT
Hello Folks.
I'm trying to read an XML formatted file via Altova but being a beginner in XML (and Altova) there is a problem that I can't understand and I would ask you to illuminate me.
It is a complex problem also because it seems related to some non "well formatted" document, but the document is produced by the EBAY Api!

Well, I don't think that Ebay - which is a solid company that is founding half of its own business on the XML document exchange - can deliver any incorrectly formatted document, all this seems at least crazy to me.

In the small file that I include in this post there is a node called "<DetailsURL>" which has a long url in it. In this url - as obvious - there are many "=" signs that Altova says are "grammatical errors" !!

Also some other tools refuse to process this file.
ColdFusion 8 simply outputs an error 500.
I'm worried about this, because this is the output of the EBAY API and I'm studying to make an application to query EBAY.
Is there someone who can help me come out from this mess and explain to me what am I missing ?
I deeply thank you in advance.

This is the file that I'm trying to analyze:

<?xml version="1.0" encoding="utf-8"?>
<FindHalfProductsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2007-08-23T00:38:28.171Z</Timestamp>
<Ack>Success</Ack>
<Build>e527_core_Bundled_5199934_R1</Build>
<Version>527</Version>
<PageNumber>1</PageNumber>
<ApproximatePages>109</ApproximatePages>
<MoreResults>true</MoreResults>
<TotalProducts>217</TotalProducts>
<Products>
<Product>
<Title>Harry Potter and the Order of the Phoenix by J. K. Rowling (2004)</Title>
<DetailsURL> <StockPhotoURL> <DisplayStockPhotos>true</DisplayStockPhotos>
<ProductID type="Reference">31266511</ProductID>
<ProductID type="ISBN">1234567890</ProductID>
<DomainName>Nonfiction Books</DomainName>
<ItemSpecifics>
<NameValueList>
<Name>Format</Name>
<Value>Softcover</Value>
</NameValueList>
<NameValueList>
<Name>Author</Name>
<Value>J. K. Rowling</Value>
</NameValueList>
</ItemSpecifics>
<ReviewCount>36</ReviewCount>
</Product>
<Product>
<Title>Harry Potter and the Sorcerers Stone by Jill Daniels (2001)</Title>
<DetailsURL> <StockPhotoURL> <DisplayStockPhotos>true</DisplayStockPhotos>
<ProductID type="Reference">8793876</ProductID>
<ProductID type="ISBN">9780439294829</ProductID>
<ProductID type="ISBN">0439294827</ProductID>
<DomainName>Nonfiction Books</DomainName>
<ItemSpecifics>
<NameValueList>
<Name>Format</Name>
<Value>Hardcover</Value>
</NameValueList>
<NameValueList>
<Name>Author</Name>
<Value>Jill Daniels</Value>
</NameValueList>
</ItemSpecifics>
<ReviewCount>0</ReviewCount>
</Product>
</Products>
</FindHalfProductsResponse>

Thanks to everyone at least for your attention.

Sergio
 
The text, shown as such, of the tag, DetailsURL, should be enclosed by <![CDATA[...]]>.
 
Or you could just change &ShowAttributesTable to &amp;ShowAttributesTable in both of the DetailsURL tags.

And it's "well-formed," not "well-formatted." XML has a small but very specific vocabulary. You should know that format means very little in XML. (Now you know.)

(You really expect eBay to be infallible?)
 
tsuji, harebrain,

first thanks for your quick reply.
And yes, it is of course "well formed", not well formatted !.
About Ebay I think that it is quite difficult to think that a large multinational organization is making trivial programming errors: I can't be the first one that uses this file to start playing around with their API.
Difficult but not impossible, of course...
I have no possibility to modify this file, because this file is the model of files that are returned by the Ebay API after a query to the Shopping.Api
So what I'm wondering here is, is this file bugged ?
I mean, may they have done an error in the "forming" syntax that doesn't take into account some kind of "escaping" technique or dialect or grammatic rule so the string with the url is bugged?
In this case instead to use a common XML_TO_STRUCTURE code that I may find on the internet - for instance the commands in ColdFusion - I have to write one by myself.
In your opinion is this file bugged ?
In this case I have to go to find out if I have got the right fileor ask to Ebay to check this file about the error that they may have done in dealing with it.
Do you agree with me ?

Thanks again for your opinions.

Sergio
 
>And it's "well-formed," not "well-formatted."
>And yes, it is of course "well formed", not well formatted !.
Those are not mine. There is no such thing as "well-formed" and/but not "well-formatted" in the realm of xml within the scope of w3c recommendation.

I meant literally what I said. It should be enclosed by the <![CDATA[ ... ]]> structure and that's all. Without that CDATA made explicit, & should be replaced by &amp; and &amp; should be replaced by &amp;amp;. The query string has every right to have ampersand in its name, if the scripter wants to transmit that info to the recipent.
 
tsuji,
May you write how it should be written ?

 
I meant simply this: the original so presented is simply _not_ well-formed. This is the minimal measure to salvage the text node (under the condition that the message/data is really what the original scripters wanted to deliver to begin with which is by all means not immediately clear though and can have plenty of space for them to ascertain.)

I artificially break the line at the positions I highlighted so that it won't appear as a wide-post in the forum. Those line-breaks are not meant to be there
[tt]
<DetailsURL>[red]<![CDATA[[/red][ignore][/ignore][highlight]?[/highlight]
PageSyiProductDetails&amp;IncludeAttributes=[highlight]1[/highlight]
&ShowAttributesTable=1&amp;ProductMementoString=80671:2:1055[highlight]:[/highlight]
2284604981:57843881:7792a32407cb7d2a381f0fa6589b5990:1:1:1:8888877611[red]]]>[/red]</DetailsURL>
[/tt]
Similarly for other DetailsURL tag.
 
Thanks a lot boy !
I modified the file introducing the CDATA specification and Altova digested the file with ease.
So I'm going to try also in ColdFusion to see if it does the same.
In this case I will manipulate te Ebay output introducing the CDATA spec before to let my other units to convert it in a query or a structure or something else.

You great boy.

Thanks

Sergio
 
There are 5 charaters that are strictly reserved as XML entities:

& " ' < >

Fields containing these characters always must either be enclosed within the CDATA tag or converted to their entity representations:

& -- &amp;
" -- &quot;
' -- &apos;
< -- &lt;
> -- &gt;
 
tsuji said:
Those are not mine. There is no such thing as "well-formed" and/but not "well-formatted" in the realm of xml within the scope of w3c recommendation.
But:
W3C

Extensible Markup Language (XML) 1.0 (Fourth Edition)

W3C Recommendation 16 August 2006, edited in place 29 September 2006

2. Definition: A data object is an XML document if it is well-formed, as defined in this specification.

Ok, tsuji, just what's your problem with this?
 
And from section 2.4 of the same document:
The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively.
So it is all exactly in the W3C Recommendation.
 
That is not the point. I don't have a problem with the quoted lines from w3c recommendation. So if it is "well-formed", it is. There isn't such thing as it being "well-formed" but not "well-formatted".
 
Ah, I see, that was the point: the term is "well-formed." "Well-formatted" is meaningless, which is what I was trying to point out to the OP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top