View Single Post
  #3 (permalink)  
Old March 29th, 2012, 11:19 AM
jonnyuk3 jonnyuk3 is offline
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks for the reply.

I am able to output the information I want to a csv file but want to output this to xml, how would i go about that?

Here's what i currently have:

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
	
<xsl:variable name="product_group" select="document('product_group.xml')/ProductGroups"/>
<xsl:variable name="stock_inventory" select="document('stock_inventory.xml')/Company"/>
	
<xsl:template match="/">
    
	<xsl:text>"ProductGroupCode"</xsl:text>
	<xsl:text>,</xsl:text>
	<xsl:text>"ProductGroupDesc"</xsl:text>
	<xsl:text>,</xsl:text>
	<xsl:text>"SKU"</xsl:text>
	<xsl:text>,</xsl:text>
	<xsl:text>"Name"</xsl:text>
	<xsl:text>,</xsl:text>
	<xsl:text>"QtyInStock"</xsl:text>
	<xsl:text>,</xsl:text>
	
	<xsl:for-each select="Company/Products/Product[Attributes/Attribute[Name='Current Stock' and Value='Yes']]">
		<xsl:sort select="Sku"/>
		
		<xsl:variable name="original_sku" select="Sku"></xsl:variable>
		
		<!-- Product group code -->
		<xsl:text>"</xsl:text>
		<xsl:value-of select="$product_group/ProductGroup[Sku=$original_sku]/ProductGroupCode"/>
		<xsl:text>"</xsl:text>
		<xsl:text>,</xsl:text>
		<!-- Product group description -->
		<xsl:text>"</xsl:text>
		<xsl:value-of select="$product_group/ProductGroup[Sku=$original_sku]/Description"/>
		<xsl:text>"</xsl:text>
		<xsl:text>,</xsl:text>
		<!-- output sku -->
		<xsl:text>"</xsl:text>
		<xsl:value-of select="Sku"/>
		<xsl:text>"</xsl:text>
		<xsl:text>,</xsl:text>
		<!-- output name -->
		<xsl:text>"</xsl:text>
		<xsl:value-of select="Name"/>
		<xsl:text>"</xsl:text>
		<xsl:text>,</xsl:text>
		<!-- qty in stock -->
		<xsl:text>"</xsl:text>
		<xsl:value-of select="$stock_inventory/Inventories/Inventory[Sku=$original_sku]/Locations/Location/QtyInStock"/>
		<xsl:text>"</xsl:text>
		<xsl:text>,</xsl:text>
		
                <!--add the newline character at the end-->
		<xsl:text>&#xa;</xsl:text>		
	</xsl:for-each>
	
</xsl:template> 
</xsl:stylesheet>
I am sure this isn't too far away, I just need another nudge in the right direction.

Thanks

jonnyuk3