June 21st, 2001, 05:27 AM
XML Help Needed
Say I have a simple XML file including this:
I need the XML file to know that the two instances of "shirt" are the same, so something like this:
<ProductInfo>The <item>shirt</item> comes in 3 sizes.</ProductInfo>
<Comments>One <item>shirt</item> costs £10</Comments>
...something to that effect, but obviously I'm doing it the wrong way.
<ProductInfo>The <item id="S3"/> comes in 3 sizes.</ProductInfo>
<Comments>One <item id="S3"/> costs £10</Comments>
<item id="S3" name="shirt"/>
What I want to achieve is a document that will look like this:
The shirt comes in 3 sizes.
One shirt costs £10
...so if I change "shirt" to "t-shirt" it will change in both places.
I'm finding it quite difficult to explain, but I hope you understand and can help me.
June 29th, 2001, 01:38 AM
What are planning to use to generate the resulting document? Because on it's own XML is just a tag language and there are many applications/ways of transforming XML into something viewable.
Also, typically one would not mix data with pseudo-formatted output in the same document. Usuallly you have things broken into data and view transforms.
For example, if you use XML with XSL, you might have the following documents. Your XML document would have the data:
<item type="shirt" cost="10" numsizes="3"/>
And your XSL document would define how to output that into say HTML. Here's an XSL fragment:
<p>The <xsl:value-of select="@type"/> comes in <xsl:value-of select="@numsizes"/> sizes.</p>
So the key is how do you plan to view your XML?