next
|
Subject: spliting xml files by certain amount Author: James Durning Date: 09 Jun 2008 11:11 AM
|
Processing time must be a killer too. If you have just a hundred thousand products, you're checking each of those nodes a hundred times!! Meaning 100*100,000 = 10,000,000 checks!
Seriously, I would recommend breaking it out with a scripting language, like perl or php. What do you mean it's not in the right format? Can you not add a <catalog> at the beginning and a </catalog> at the end of each segment?
At least with running the same transformation on multiple files, you can use a CompiledTransform, and speed up your processing time there too.
-----
If you choose not to do it this way, I still recommend using a single stylesheet. Instead use 2 stylesheet parameters:
<xsl:param name="low" select="0">
<xsl:param name="high" select="1000">
Pass in the appropriate values to the process in each run.
Only problem is you have to know how many nodes there in your main file, unless you check your output is empty, through file size or other means.
--
Further, have you noticed you're missing products 1000,2000,3000,4000?
Need a equal sign in the comparison:
<xsl:for each select="catalog/product[position() > $low and position() <= $high]>
|
next
|
Subject: spliting xml files by certain amount Author: tyler horath Date: 09 Jun 2008 11:17 PM Originally Posted: 09 Jun 2008 10:38 PM
|
Here is my code. When it generates the file, they do not contain anything..
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/">
<AspDotNetStorefrontImportFile>
<xsl:for-each select="catalog/product[position() mod 1000 = 1]">
<xsl:variable name="filename" select="concat('file:///','AA','_', position(),'.xml')"/>
<xsl:result-document href="{$filename}">
<xsl:for-each select=". | following-sibling::catalog/product[position() < 1000]">
<Product>
<Name><xsl:value-of select="name"/></Name>
<ProductTypeRef>Generic Product</ProductTypeRef>
<ManufacturerRef><xsl:value-of select="manufacturer"/></ManufacturerRef>
<DistributorRef><xsl:value-of select="programname"/></DistributorRef>
<CategoryRef/>
<Summary/>
<Description><xsl:value-of select="description"/></Description>
<SEKeywords><xsl:value-of select="keywords"/></SEKeywords>
<SEDescription><xsl:value-of select="concat(substring(description, 1, 100), '...')"/></SEDescription>
<SETitle><xsl:value-of select="name"/></SETitle>
<SKU><xsl:value-of select="sku"/></SKU>
<ManufacturerPartNumber/>
<XmlPackage>product.affiliate.xml.config</XmlPackage>
<ColWidth>4</ColWidth>
<SalesPromptID>1</SalesPromptID>
<Published>1</Published>
<RequiresRegistration>0</RequiresRegistration>
<MiscText><xsl:value-of select="buyurl"/></MiscText>
<TrackInventoryBySizeAndColor>0</TrackInventoryBySizeAndColor>
<ImageFilenameOverride><xsl:value-of select="impressionurl"/></ImageFilenameOverride>
<ExtensionData><xsl:value-of select="imageurl"/></ExtensionData>
<IsAKit/>
<IsAPack/>
<PackSize/>
<ProductVariant>
<Name><xsl:value-of select="name"/></Name>
<IsDefault>1</IsDefault>
<SKUSuffix/>
<ManufacturerPartNumber/>
<Description><xsl:value-of select="description"/></Description>
<SEKeywords><xsl:value-of select="keywords"/></SEKeywords>
<SEDescription><xsl:value-of select="concat(substring(description, 1, 50), '...')"/></SEDescription>
<SETitle><xsl:value-of select="name"/></SETitle>
<Price><xsl:value-of select="price"/></Price>
<SalePrice><xsl:value-of select="saleprice"/></SalePrice>
<MSRP><xsl:value-of select="retailprice"/></MSRP>
<Cost/>
<Weight/>
<Dimensions/>
<Inventory>1000000</Inventory>
<DisplayOrder>1</DisplayOrder>
<Colors/>
<ColorSKUModifiers/>
<Sizes/>
<SizeSKUModifiers/>
<IsTaxable>0</IsTaxable>
<IsShipSeparately>0</IsShipSeparately>
<IsDownload>1</IsDownload>
<DownloadLocation>1</DownloadLocation>
<Published>1</Published>
<ImageFilenameOverride><xsl:value-of select="impressionurl"/></ImageFilenameOverride>
<ExtensionData><xsl:value-of select="imageurl"/></ExtensionData>
</ProductVariant>
</Product>
</xsl:for-each>
</xsl:result-document>
</xsl:for-each>
</AspDotNetStorefrontImportFile>
</xsl:template>
</xsl:stylesheet>
|
|