I am using a 3rd party software to generate an XML-file. This software allows to use a post-processor in form of XSLT (2.0).
My output files are rather huge, often reaching multiple hundred MB and several million of lines. I want to chunk my output files and have 1 file after each (lets say 10 products) instead of all in one file.
I found a smiliar thread here: Split one XML file to multiple XML File with XSLT but since I'm completly new to XSLT, I can't figure out on how to give a specific range at which the files will be splitted. I assume xsl:for-each select="document/file">
from the given example is the expression where to look, but I'm not certain either.
A simple XML looks a bit like this:
<Products>
<Product ID="123" UserType="ITEM">
<Name>First Product</Name>
<Values>
<Value AttributeID="someAttribute">foo</Value>
<Value AttributeID="AnotherAttribute">bar</Value>
</Values>
</Product>
<Product ID="456" UserType="ITEM">
<Name>Second Product</Name>
<Values>
<Value AttributeID="someAttribute">foo</Value>
<Value AttributeID="AnotherAttribute">bar</Value>
</Values>
</Product>
</Products>
As mentioned above, there are multiple thousands of products and for the sake of a clean overview, I left out the nodes before and after the <Products>
-node.
How can I split my one given output-file to N files, which are split after lets say 10 products?
question from:
https://stackoverflow.com/questions/65898634/split-one-out-file-into-multiple-xmls-after-n-elements 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…