I have figured out the issue that was preventing the Xpath select from working as expected. Apparently, with XSLT 1.0, if you have a default namespace in your source XML document (which the wsn-notification document will have), you must include that same namespace in your XSL file, with a prefix, and then attach that prefix to each of the elements in youe Xpath query. The working XSL is immediately below:
<?xml version="1.0"?> <!-- START SNIPPET: route --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jbi="xalan://org.servicemix.components.xslt.XalanExtension" xmlns:wsn="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1. 2-draft-01.xsd" extension-element-prefixes="jbi" xmlns:demo="http://servicemix.org/demo" version="1.0"> <xsl:template match="/*"> <xsl:variable name="receiverID"> <xsl:value-of select="wsn:ceXML/wsn:CexpInvoice/wsn:ReceiverID/text()"/> </xsl:variable> <xsl:choose> <!-- lets forward the inbound message to a service --> <xsl:when test="$receiverID='PEOPLESOFT'"> <jbi:invoke service="demo:subscriber"> <jbi:copyProperties/> <xsl:copy-of select="/"/> </jbi:invoke> </xsl:when> <xsl:otherwise> <jbi:invoke service="demo:receiver"> <jbi:copyProperties/> <xsl:copy-of select="/"/> </jbi:invoke> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> <!-- END SNIPPET: route --> > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 07, 2005 7:11 PM > To: [email protected] > Subject: RE: [servicemix-user] XPath Router Question > > > A followup, the following XSL functions properly in XML Spy, > but seems to > have no effect in ServiceMix: > > <?xml version="1.0"?> > <!-- START SNIPPET: route --> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:jbi="xalan://org.servicemix.components.xslt.XalanExtension" > extension-element-prefixes="jbi" > xmlns:demo="http://servicemix.org/demo" > version="1.0"> > <xsl:template match="/*"> > <xsl:variable name="receiverID"> > <xsl:value-of > select="ceXML/CexpInvoice/ReceiverID/text()"/> > </xsl:variable> > <xsl:choose> > <!-- lets forward the inbound message > to a service > --> > <xsl:when test="$receiverID='PEOPLESOFT'"> > <jbi:invoke service="demo:subscriber"> > <jbi:copyProperties/> > <xsl:copy-of select="/"/> > </jbi:invoke> > </xsl:when> > <xsl:otherwise> > <!-- not working <jbi:forward > service="demo:subscriber"/> --> > <jbi:invoke service="demo:receiver"> > <jbi:copyProperties/> > <xsl:copy-of select="/"/> > </jbi:invoke> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > </xsl:stylesheet> > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, December 07, 2005 6:18 PM > > To: [email protected] > > Subject: [servicemix-user] XPath Router Question > > > > > > I know that I'm missing something obvious here, and am > > hopeful that some one > > will be able to point out my folly to me. I am working on a > > simple XPath > > Router that should perform a query on the body of an incoming > > XML message > > and route appropriately. My logic is as follows: > > > > <xsl:template match="/*"> > > <xsl:choose> > > <xsl:when test="ceXML/CexpInvoice/RecieverID/text() = > > 'PEOPLESOFT'"> > > <jbi:invoke ... > > </xsl:when> > > <xsl:otherwise> > > <jbi:invoke ... > > </xsl:otherwise> > > > > The body of the XML looks like this: > > <!xml version="1.0" encoding="UTF-8"?> > > <Message xmlns="..."> > > <ceXML> > > <CexpInvoice> > > <ReceiverID>PEOPLESOFT</ReceiverID> > > <SenderID>12345</SenderID> > > <TransactionID>TRD</TransactionID> > > > > > > I'd think that the match command positions me within the > > <Message> node, so > > that the comparison should be from that point on down. This > > code never works > > as expected - the <xsl:otherwise> route is always selected, > > so I think that > > my XPat is bad. Any help is appreciated. > > > > /jonathan > > >
