|
next
|
Subject: XML data import with XSL Stylesheet and missing child node Author: bob williams Date: 05 Oct 2007 05:28 PM Originally Posted: 02 Oct 2007 07:45 PM
|
I'm a newbie.... So if my explanation leaves a bit to be desired I'm sorry. But basically I need to create a child node if one doesn't exist.
I am importing data via XML into my database so I don't want to wade through any HTML design if possible to find what I need.
Here's what I have: 1 record with several items of data importing using my XSL Stylesheet. Repeating data into separate fields...
Simplified example of XML data nodes:
<items>
<Item>
<ItemName><DatePurchased><LastSaleDate><Cost><ListPrice>
</item>
<Item>
<ItemName><DatePurchased><Cost><ListPrice>
</item>
<Item>
<ItemName><DatePurchased><LastSaleDate><Cost><ListPrice>
</item>
</items>
Data coming into each field:
ItemName,DatePurchased, LastSaleDate, Cost, ListPrice,
shelf1, 1/1/2007, 2/2/2007 ,$10.00,$20.00
shelf2, 1/1/2007,(Empty so no node present),$10.00,$17.50
shelf3, 1/1/2007, 2/2/2007 ,$10.00,$20.00
But it looks like:
Field1 field2 field3 field4 field5
shelf1, 1/1/2007 2/2/2007 $10.00 $20.00
shelf2, 1/1/2007 2/2/2007 $10.00 $17.50
shelf3, 1/1/2007 (moved up) $10.00 $20.00
Problem: The data below the missing child node moves up in the field.
I'm using <xsl:for-each> and <xsl:value-of select="." /> as such...
<COL>
<DATA>
<xsl:for-each select="Items/Item/ItemName" > ***Reason if I get an error it comes in under <Items><Error Message> ****
<xsl:value-of select="." />
<xsl:text>
</xsl:text>
</xsl:for-each>
</DATA>
</COL>
<COL>
<COL>
<DATA>
<xsl:for-each select="Items/Item/DatePurchased" >
<xsl:value-of select="." />
<xsl:text>
</xsl:text>
</xsl:for-each>
</DATA>
</COL>
<COL>
You get the idea.......
I've read a lot but I'm out of time and need to finish this so I can get back to my real job.
|
|
|