XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Steve WarburtonSubject: adding tables and relationships
Author: Steve Warburton
Date: 29 Mar 2007 08:42 PM
I am new to xml but have experience with databases. I am trying to create a schema that will link some xml files. (I think thats what I need).
I have 3 files from a web cart as follows:
categories:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE category (View Source for full doctype...)>
- <category xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="testshema.xsd">
<category category_id="4" category_name="Cleaning%20stuff" category_description="Our%20range%20of%20cleaning%20fluids%20etc" category_pagestyle="default%5Fcategory%5Fstyle" category_image="noimage%2Ejpg" category_order="4" />
<category category_id="3" category_name="Steri%2Dx" category_description="Steriex%20Products%20etc%20etc%20etc" category_pagestyle="default%5Fcategory%5Fstyle" category_image="Polaris%20tank%20top%20view2%2Ejpg" category_order="3" />
<category category_id="5" category_name="KING%20NUT" category_description="All%20the%20details%20about%20the%20king%20nut%20etc%20etc" category_pagestyle="default%5Fcategory%5Fstyle" category_image="KingNutAnimation%2Eswf" category_order="2" />
<category category_id="1" category_name="Parkforce" category_description="Parkforce%20text%20has%20now%20changed" category_pagestyle="default%5Fcategory%5Fstyle" category_image="none" category_order="5" />
<category category_id="6" category_name="6th cat" category_description="6th test" category_pagestyle="default%5Fcategory%5Fstyle" category_order="6" />
</category>
subcategories:
<?xml version="1.0" encoding="UTF-8" ?>
- <subcategory>
<subcategory subcategory_id="8" subcategory_name="Workshop%20cleaners%20%26%20oils" subcategory_category_id="4" subcategory_desc_cat="Short%20Description%20Unavailable%2E" subcategory_desc_subcat="Long%20Description%20Unavailable%2E" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="noimage%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="8" />
<subcategory subcategory_id="7" subcategory_name="Car%20Care" subcategory_category_id="4" subcategory_desc_cat="Short%20Description%20Unavailable%2E" subcategory_desc_subcat="Long%20Description%20Unavailable%2E" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="noimage%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="7" />
<subcategory subcategory_id="6" subcategory_name="Industrial%20Cleaners" subcategory_category_id="4" subcategory_desc_cat="Short%20Description%20Unavailable%2E" subcategory_desc_subcat="Long%20Description%20Unavailable%2E" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="noimage%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="6" />
<subcategory subcategory_id="5" subcategory_name="Domestic%20Cleaning%20%2F%20Household" subcategory_category_id="4" subcategory_desc_cat="Short%20Description%20Unavailable%2E" subcategory_desc_subcat="Long%20Description%20Unavailable%2E" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="noimage%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="5" />
<subcategory subcategory_id="1" subcategory_name="The%20Parkforce%20system" subcategory_category_id="1" subcategory_desc_cat="Details%20of%20parkforce%20etc" subcategory_desc_subcat="long%20description%2E%20ref%20parking" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="62%2Ejpg" subcategory_image_subcat="62%2Ejpg" subcategory_order="1" />
<subcategory subcategory_id="2" subcategory_name="ANPR" subcategory_category_id="1" subcategory_desc_cat="Nuber%20plate%20recognition%20etc%20" subcategory_desc_subcat="All%20to%20do%20with%20anpr" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="spv%5Fm1500%5Flge%2Egif" subcategory_image_subcat="Pocket%20PC1%2Ejpg" subcategory_order="2" />
<subcategory subcategory_id="3" subcategory_name="steri%2Dx%20sub%20cat%20%233" subcategory_category_id="3" subcategory_desc_cat="No%20description%2E" subcategory_desc_subcat="No%20description%2E" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="noimage%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="3" />
<subcategory subcategory_id="4" subcategory_name="Product%20Line%20%234" subcategory_category_id="5" subcategory_desc_cat="king%20nut%20sub%20cat%201" subcategory_desc_subcat="King%20nut%20cat1%20long%20desc" subcategory_pagestyle="default%5Fsubcategory%5Fstyle" subcategory_capsule_style="grid" subcategory_image_cat="Kingnut%20animation%2Ejpg" subcategory_image_subcat="noimage%2Ejpg" subcategory_order="4" />
</subcategory>
store:
<?xml version="1.0" encoding="UTF-8" ?>
- <inventory>
<inventory sku="15" status="available" name="Product%206" price="20" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="14" status="available" name="Product%205" price="6" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="13" status="available" name="Product%204" price="4" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="12" status="available" name="Product%203" price="2" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="11" status="available" name="Product%202" price="5" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="10" status="available" name="Product%201" price="7%2E5" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="0" category_id="4" subcategory_id="8" media="none" file="none" />
<inventory sku="park1" status="available" name="The%20Parkforce%20solution%20kits" price="99" shipping1="15" shipping2="0" handling="0" description="We%20offer%20landowners%20in%20the%20UK%20an%20ethical%2C%20lawful%2C%20non%2Dconfrontational%20and%20cost%20effective%20alternative%20to%20wheel%20clamping%20to%20solve%20the%20problem%20of%20unlawful%20parking%20on%20privately%20owned%20land%2E%20%0D%0DOur%20system%20of%20parking%20control%2C%20%E2%80%9CThe%20Parkforce%20Solution%E2%80%9D%20is%20based%20on%20the%20issuing%20of%20%E2%80%9Ccivil%20notice%20to%20driver%20stickers%E2%80%9D%20and%20%2F%20or%2C%20the%20issuing%20of%20parking%20charge%20tickets%20to%20unlawfully%20parked%20vehicles%20on%20privately%20owned%20land%2E%0D" discount="0" image_small="62%2Ejpg" image_small_scale="scale" image_medium="62%2Ejpg" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="2" options2_id="%2D1" options3_id="%2D1" weight="1" category_id="1" subcategory_id="1" media="none" file="none" />
<inventory sku="demo8" status="available" name="Sterix%20Product%20%238" price="110" shipping1="0" shipping2="0" handling="0" description="Description%20for%20strex%208" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="3" subcategory_id="3" media="none" file="none" />
<inventory sku="demo7" status="available" name="King%20nut%20box%201" price="0" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="5" subcategory_id="4" media="none" file="none" />
<inventory sku="demo600" status="available" name="Sterix%20Product%20%236" price="210" shipping1="0" shipping2="0" handling="0" description="Description%20for%20strex%206" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="3" subcategory_id="3" media="none" file="none" />
<inventory sku="demo5" status="available" name="Sterix%20Product%20%235" price="210" shipping1="0" shipping2="0" handling="0" description="Description%20for%20strex%205" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="3" subcategory_id="3" media="none" file="none" />
<inventory sku="demo4" status="available" name="Demo%20Product%20%234" price="0" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="1" subcategory_id="2" media="none" file="none" />
<inventory sku="demo3" status="available" name="Demo%20Product%20%233" price="0" shipping1="0" shipping2="0" handling="0" description="Description%20unavailable%2E" discount="0" image_small="none" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="0" options2_id="0" options3_id="0" weight="1" category_id="1" subcategory_id="2" media="none" file="none" />
<inventory sku="park2" status="available" name="Standard%20Signs%20for%20paul" price="10" shipping1="0" shipping2="0" handling="0" description="Additional%20standard%20signs%2E%2018%22%20X%2016%22" discount="0" image_small="62%2Ejpg" image_small_scale="scale" image_medium="Pocket%20PC1%2Ejpg" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="2" options2_id="0" options3_id="%2D1" weight="1" category_id="1" subcategory_id="1" media="none" file="none" />
<inventory sku="park3" status="available" name="Extra%20wording" price="15" shipping1="0" shipping2="0" handling="0" description="%20Change%20wording%20on%20signs%2E%20EG%20%22CUSTOMERS%20OF%20THE%20BULL%20HEADS%20WHILST%20ON%20THE%20PREMISES%22" discount="0" image_small="62%2Ejpg" image_small_scale="scale" image_medium="none" image_medium_scale="scale" image_large="none" image_large_scale="scale" options1_id="%2D1" options2_id="%2D1" options3_id="%2D1" weight="1" category_id="1" subcategory_id="1" media="none" file="none" />
</inventory>

In a database I create master relationships within Delphi. How do I do this with Stylus studio. I have openend the 3 files but cannot work out how to 'link' them together.

Cheers

SteveW

Postnext
Elias HuterSubject: adding tables and relationships
Author: Elias Huter
Date: 30 Mar 2007 06:47 AM
I don't know if there is a special technique to solve this problem (can XSLT handle more than one input file?), but I would do it that way:

- First somehow (not XSLT) get the 3 XML Files into one XML file with one XML Tag:

Before:
<?xml version="1.0" encoding="UTF-8" ?>
<a_line1/>
<a_line2/>

<?xml version="1.0" encoding="UTF-8" ?>
<b_line1/>
<b_line2/>

<?xml version="1.0" encoding="UTF-8" ?>
<c_line1/>
<c_line2/>

After:
<?xml version="1.0" encoding="UTF-8" ?>
<a>
<a_line1/>
<a_line2/>
</a>
<b>
<b_line1/>
<b_line2/>
</b>
<c>
<c_line1/>
<c_line2/>
</c>

Now you can make an XSLT mapping. Find out which information belongs together according to their key fields.

Somehow like this (assuming that "a" contains all keys and its a 1-1 relationship):

<xsl:for-each "a">

<!-- Take name from a -->
<name>
<xsl:value-of "name"/>
</name>

<!-- Take productid from b, find it via id -->
<porductid>
<xsl:value-of "b[id = a/id]/productid">
</productid>

<!-- Take vendor from c, find it via id -->
<vendor>
<xsl:value-of "c[id = a/id]/vendor">
</vendor>

</xsl:for-each>

Postnext
Steve WarburtonSubject: adding tables and relationships
Author: Steve Warburton
Date: 30 Mar 2007 07:23 AM
Unfortunately I cannot manipulate the data as it has to be read by the shopping cart software.

Thanks for the help anyway

SteveW

Postnext
Elias HuterSubject: adding tables and relationships
Author: Elias Huter
Date: 30 Mar 2007 07:43 AM
Maybe this Thread helps you, there is an example how to merge XML Files:

http://www.stylusstudio.com/SSDN/default.asp?action=9&read=3902&fid=48&style=WebBoard

Postnext
Steve WarburtonSubject: adding tables and relationships
Author: Steve Warburton
Date: 30 Mar 2007 07:56 AM
Unfortunately I cannot manipulate the data as it has to be read by the shopping cart software.

Thanks for the help anyway

SteveW

Posttop
Elias HuterSubject: adding tables and relationships
Author: Elias Huter
Date: 30 Mar 2007 08:25 AM
So what's exactly what you want if you don't want to merge the data? At some point you will want to modify the data don't you?

Also you wouldn't manipulate the input files if you do it like they show you in the link above. In your example you would have 3 input streams and 1 output stream, the 3 input streams would stay unmodified.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.