Page 1 of 1

XML Question for SS Staff

PostPosted: Fri Oct 31, 2003 12:34 pm
by David Clarke
This XML strikes me as odd.
The number of order options is not self describing.
The only way to know how many order options there are for a given product is
to
subtract 10 from the Product Children Count.
Which could lead to future data errors if you add to the products xml node.

The fact that there can be a variable number of Order Options
would lead me to think Order Options needs a node of
its own.

CURRENT SHOP SITE XML:

/ShopSiteOrders/[18]/[4]/[7] Product 12


/ShopSiteOrders/[18]/[4]/[7]/[10] OrderOption 2
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2] OptionPrice
/ShopSiteOrders/[18]/[4]/[7]/[11] OrderOption 2
/ShopSiteOrders/[18]/[4]/[7]/[11]/[1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[11]/[2] OptionPrice

/ShopSiteOrders/[18]/[4]/[7]/[12] CustomerText


ISN'T THIS BETTER:

/ShopSiteOrders/[18]/[4]/[7] Product 12

/ShopSiteOrders/[18]/[4]/[7]/[10] OrderOptions 2
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1][1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1][2] OptionPrice
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2][1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2][2] OptionPrice

/ShopSiteOrders/[18]/[4]/[7]/[11] CustomerText


I am bring this up because I think the XML interface is GREAT!


Thanks
David Clarke

Re: XML Question for SS Staff

PostPosted: Sat Nov 01, 2003 5:22 pm
by Keith Petty
Hi David,

If you are simply counting "nodes / elements" to parse through the
information then you could have a problem if the number of "nodes /
elements" in the "XML" file structure were to change .

However... if you are using a good "XML Parser" to assist with the job
then it should not retrieve the information by a number but by actually
identifying items by their "tag name", eliminating any need for counting
"tags" and locating things using some mathematical formula.

It should be able to locate all the "child elements / nodes" of the
"<Product>" section including any "<OrderOption>" no matter how many
other xml "tags" come before it, or after it.

It should also be able to iterate through any number (from "1 to x" -
however many x is...) of "<OrderOption>" sections one at a time.

I have placed an example below from one of my orders which has (2) two
"<OrderOption>" sections.

- <Product>
<ProdType>Tangible</ProdType>
<Name>14KT Yellow Gold Small Name Ring</Name>
<SKU>brsmall</SKU>
<Taxable>Yes</Taxable>
<Quantity>1</Quantity>
<ItemPrice>89.00</ItemPrice>
<Total>89.00</Total>
<Weight/>
<Dimension/>
- <OrderOption>
<SelectedOption>One i - Add 1 diamond for $10.00</SelectedOption>
<OptionPrice>10.00</OptionPrice>
</OrderOption>
- <OrderOption>
<SelectedOption>Size 7.5</SelectedOption>
<OptionPrice/>
</OrderOption>
<CustomerText>Kim</CustomerText>
</Product>


A simple "while" loop in some code (what ever language you are using)
would check to see if an "<OrderOption>" section existed.
If so parse through it.
Then move to the next "Element / node / tag".
Go back to the top of the "while" loop and check it again.

It might look something like this:

while( OrderOptionElement != null){
// parse the needed data for this option ...
// get the next element
}

Hope this helps...
Keith :-)
The "Beast"
1 part JavaBean,
2 part Cellular or Radio Frequency Communications
1 part XML
1 part XSLT
1 part DTD
1 part Java enabled Server
1 part Java Servlet
Mix thoroughly for Big Brother "Identification and Tracking".



David Clarke wrote:

This XML strikes me as odd.
The number of order options is not self describing.
The only way to know how many order options there are for a given product is
to
subtract 10 from the Product Children Count.
Which could lead to future data errors if you add to the products xml node.

The fact that there can be a variable number of Order Options
would lead me to think Order Options needs a node of
its own.

CURRENT SHOP SITE XML:

/ShopSiteOrders/[18]/[4]/[7] Product 12


/ShopSiteOrders/[18]/[4]/[7]/[10] OrderOption 2
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2] OptionPrice
/ShopSiteOrders/[18]/[4]/[7]/[11] OrderOption 2
/ShopSiteOrders/[18]/[4]/[7]/[11]/[1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[11]/[2] OptionPrice

/ShopSiteOrders/[18]/[4]/[7]/[12] CustomerText


ISN'T THIS BETTER:

/ShopSiteOrders/[18]/[4]/[7] Product 12

/ShopSiteOrders/[18]/[4]/[7]/[10] OrderOptions 2
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1][1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[1][2] OptionPrice
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2][1] SelectedOption
/ShopSiteOrders/[18]/[4]/[7]/[10]/[2][2] OptionPrice

/ShopSiteOrders/[18]/[4]/[7]/[11] CustomerText


I am bring this up because I think the XML interface is GREAT!


Thanks
David Clarke








Re: XML Question for SS Staff

PostPosted: Sun Nov 02, 2003 7:33 am
by David Clarke
Keith:

Thank you for your through and correct answer. I was perplexed because in
sections like TOTALS the TAX, SHIPPINGTOTAL and SURCHARGE got children but
in PRODUCT the ORDEROPTION didn't. And since order options always travel in
pairs and there could be 0 or more of them. Oh well, no big deal I will
change my code as per your recommended and just look at all the tag names.

I have been working with ShopSite for almost 5 years. Every time they
release an upgrade my upload / download utilities stop working because they
change something. I am hoping the xml will prevent that in the future.

Thanks Again

David Clarke