2007/12/27, Robert Thullner <[EMAIL PROTECTED]>: > Hi > > I have an XML Message that is send over JMS which I would like to be > splitted. The message looks like this > > <instruction> > <header1>...</header1> > <header2>...</header2> > ... > <stages> > <stage> > <stageInfo1> ... </stageInfo1> > ... > </stage> > > <stage> > <stageInfo1> ... </stageInfo1> > ... > </stage> > </stages> > </instruction> > > What I want now is to split the message so that each message contains the > complete header and one stage. > > Do you have any suggestions?
What I did in very similar case is I sent such message to XSLT endpoint first. That XSLT looks like: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:agg="http://activemq.apache.org/camel/schema/aggregator"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <agg:aggregator> <xsl:apply-templates select="/instruction/stages/stage"/> </agg:aggregator> </xsl:template> <xsl:template match="/instruction/stages/stage"> <instruction> <xsl:copy-of select="/instruction/*[name() != 'stages' ]"/> <stages> <xsl:copy-of select="."></xsl:copy-of> </stages> </instruction> </xsl:template> </xsl:stylesheet> Then I split using XPath like "/agg:aggregator/*" I'm not really sure if you can find such XPath/XQuery expression that will split your original message to what you need. Hope it helps. Roman
