Split XML file using Information Studio in MarkLogic

buddagirls

New Member
I need to split a XML file looking like the following \[code\]<root> <Credit> <TradeId>123</TradeId> <name>abcd</name> </Credit> <Credit> <TradeId>456</TradeId> <name>efgh</name> </Credit> <Credit> <TradeId>789</TradeId> <name>ijkl</name> </Credit></root>\[/code\]into 3 separate files by the node Credit, each looking like the following:\[code\]<root> <Credit> <TradeId>123</TradeId> <name>abcd</name> </Credit></root>\[/code\]Am using the following code in the XSLT (stylesheet version 2.0) transformation option in Information Studio in MarkLogic but it is not working. It is loading the original file instead of splitting it into smaller files and loading them.\[code\]<xsl:template match="/"> <xsl:for-each select="collection(iri-to-uri('./?select=*.xml;recurse=yes'))"> <xsl:for-each select="//Credit"> <xsl:variable name="TradeId" select="TradeId" /> <xsl:variable name="filename" select="concat('./_Out/', $TradeId, .xml')" /> <xsl:value-of select="$filename" /> <xsl:result-document href="http://stackoverflow.com/questions/10835374/{$filename}"> <root> <xsl:copy-of select="node()"/> </root> </xsl:result-document> </xsl:for-each> </xsl:for-each></xsl:template>\[/code\]Am I missing something here? Thanks in advance!
 
Back
Top