Fuse ESB - Camel issue - apache-camel

We are trying to install a bundle using osgi in Fuse ESB 7.1.0.
Inside this bundle, in camel-context we are using like below:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<endpoint uri="http://IPADDRESS:8080/LOB_Webservice/LOBSampleWebService?throwExceptionOnFailure=false" id="callLOBServer"/>
<route>
<from uri="cxf:bean:lobclient?dataFormat=MESSAGE"/>
<to uri="log:output"/>
<bean ref="enrichBean"/>
<to uri="xslt:etc/8.xsl"/>
<bean ref="enrichBean"/>
<to ref="callLOBServer"/>
<bean ref="enrichBean"/>
***<to uri="xslt:etc/3.xsl"/>***
<bean ref="enrichBean"/>
<to uri="xslt:etc/7.xsl"/>
<bean ref="enrichBean"/>
<to uri="log:output"/>
</route>
</camelContext>
The above 3.xsl is using XSLT 2.0.
When we try to install this, it is getting failed with below information:
15:11:23,047 | ERROR | ExtenderThread-4 | XsltErrorListener | 147 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | A location step was expected following the '/' or '//' token.; Line#: 8; Column#: 77
15:11:23,047 | ERROR | ExtenderThread-4 | ContextLoaderListener | 113 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=org.apache.camel.camel-example-cxf-proxy, config=osgibundle:/META-INF/spring/*.xml))
java.lang.StackOverflowError
at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_07]
at org.osgi.framework.FrameworkUtil.getBundle(FrameworkUtil.java:208)[karaf.jar:2.3.0.fuse-71-047]
at org.ops4j.pax.logging.util.OsgiUtil.getBundleOrNull(OsgiUtil.java:114)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.getClassDetail(OsgiThrowableRenderer.java:148)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.formatElement(OsgiThrowableRenderer.java:135)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.doRender(OsgiThrowableRenderer.java:105)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.doRender(OsgiThrowableRenderer.java:52)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.spi.ThrowableInformation.getThrowableStrRep(ThrowableInformation.java:89)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.spi.LoggingEvent.getThrowableStrRep(LoggingEvent.java:413)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:313)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:276)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.Category.callAppenders(Category.java:193)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.log4j.Category.forcedLog(Category.java:365)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.log4j.Category.log(Category.java:772)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.ops4j.pax.logging.service.internal.PaxLoggerImpl.error(PaxLoggerImpl.java:159)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.ops4j.pax.logging.internal.TrackingLogger.error(TrackingLogger.java:96)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.ops4j.pax.logging.slf4j.Slf4jLogger.error(Slf4jLogger.java:911)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.camel.builder.xml.XsltErrorListener.fatalError(XsltErrorListener.java:44)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]
at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:614)[:]
at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1639)[:]
Here is the content of 3.xsl also.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="return">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
<ordertotal>
<xsl:value-of select="sum(orderDetails/(itemPrice * itemQty))"/>
</ordertotal>
</xsl:copy>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
But when we try to replace 3.xsl with equivalent XSLT 1.0 functionality, its working fine.
As part of requirements, we need to work with XSLT 2.0 only.
Can someone please help? Thanks.
Latest stack trace..
16:06:46,210 | ERROR | ExtenderThread-2 | XsltErrorListener | 147 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | A location step was expected following the '/' or '//' token.; Line#: 8; Column#: 78
16:06:46,210 | ERROR | ExtenderThread-2 | ContextLoaderListener | 113 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=org.apache.camel.camel-example-cxf-proxy, config=osgibundle:/META-INF/spring/*.xml))
java.lang.StackOverflowError
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:332)[:1.7.0_07]
at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1144)[:1.7.0_07]
at java.lang.ClassLoader.getClassLoadingLock(ClassLoader.java:462)[:1.7.0_07]
at java.lang.ClassLoader.loadClass(ClassLoader.java:403)[:1.7.0_07]
at java.lang.ClassLoader.loadClass(ClassLoader.java:410)[:1.7.0_07]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)[:1.7.0_07]
at java.lang.ClassLoader.loadClass(ClassLoader.java:410)[:1.7.0_07]
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
at org.apache.felix.framework.ExtensionManager$ExtensionManagerWiring.getClassByDelegation(ExtensionManager.java:873)
at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1520)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1466)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1882)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1814)
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:929)
at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)[114:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)[114:org.springframework.osgi.core:1.2.1]
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
at org.ops4j.pax.logging.util.OsgiUtil.loadClass(OsgiUtil.java:99)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.findClass(OsgiThrowableRenderer.java:221)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.formatElement(OsgiThrowableRenderer.java:134)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.doRender(OsgiThrowableRenderer.java:105)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.OsgiThrowableRenderer.doRender(OsgiThrowableRenderer.java:52)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.spi.ThrowableInformation.getThrowableStrRep(ThrowableInformation.java:89)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.spi.LoggingEvent.getThrowableStrRep(LoggingEvent.java:413)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:313)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:276)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.apache.log4j.Category.callAppenders(Category.java:193)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.log4j.Category.forcedLog(Category.java:365)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.log4j.Category.log(Category.java:772)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.ops4j.pax.logging.service.internal.PaxLoggerImpl.error(PaxLoggerImpl.java:159)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.ops4j.pax.logging.internal.TrackingLogger.error(TrackingLogger.java:96)[3:org.ops4j.pax.logging.pax-logging-service:1.7.0]
at org.ops4j.pax.logging.slf4j.Slf4jLogger.error(Slf4jLogger.java:911)[4:org.ops4j.pax.logging.pax-logging-api:1.7.0]
at org.apache.camel.builder.xml.XsltErrorListener.fatalError(XsltErrorListener.java:44)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]
at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:614)[:]
at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1639)[:]
at org.apache.xpath.compiler.XPathParser.LocationPath(XPathParser.java:1597)[:]
at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1317)[:]
at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1236)[:]
at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1142)[:]
at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1063)[:]
Input XML file
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:fetchOrderListResponse xmlns:ns2="http://impl.lob.wipro.com/">
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderDetails>
<itemPrice>50.0</itemPrice>
<itemQty>2</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>37516016-D71B-4790-951F-55D00B0CC159</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>39.0</itemPrice>
<itemQty>3</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>6095ABC7-0D0D-4B2E-92E5-80F24E9092B8</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>84EC371D-40CA-455E-A0FA-7EA733E9BFD3</orderId>
<ordertotal>0.0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderId>54712493-2172-4ADB-814B-BC7AA0BB72C3</orderId>
<ordertotal>0.0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<deliverydate>2013-02-06T00:00:00+05:30</deliverydate>
<orderDetails>
<itemPrice>565.0</itemPrice>
<itemQty>1</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>9A5030BE-F95F-4C62-B5A2-41FF85423218</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>4.0</itemPrice>
<itemQty>90</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>65A8B3BE-D407-43D8-8754-EA1E26AA56E4</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>0BDCB222-0117-47A9-8813-DF03A1D19E5E</orderId>
<ordertotal>0.0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderId>8E4220DC-884B-47BC-A565-E26B80BA5249</orderId>
<ordertotal>0.0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<deliverydate>2013-02-06T00:00:00+05:30</deliverydate>
<orderDetails>
<itemPrice>10.0</itemPrice>
<itemQty>4</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>5A2DF895-BB0F-4039-80DB-F44CED31697B</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>20.0</itemPrice>
<itemQty>3</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>8034FBF4-B573-4B19-BDF5-FAF6C4247A55</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>60161E3E-3C4A-4CE6-AAC3-E4D2BC240046</orderId>
<ordertotal>0.0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
</ns2:fetchOrderListResponse>
</soap:Body>
</soap:Envelope>
And the XSLT is as follows:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ordertotal">
<xsl:copy>
<xsl:value-of select="sum(../orderDetails/(itemPrice*itemQty))" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
output expected..
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:fetchOrderListResponse xmlns:ns2="http://impl.lob.wipro.com/">
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderDetails>
<itemPrice>50.0</itemPrice>
<itemQty>2</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>37516016-D71B-4790-951F-55D00B0CC159</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>39.0</itemPrice>
<itemQty>3</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>6095ABC7-0D0D-4B2E-92E5-80F24E9092B8</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>84EC371D-40CA-455E-A0FA-7EA733E9BFD3</orderId>
<ordertotal>217</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderId>54712493-2172-4ADB-814B-BC7AA0BB72C3</orderId>
<ordertotal>0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<deliverydate>2013-02-06T00:00:00+05:30</deliverydate>
<orderDetails>
<itemPrice>565.0</itemPrice>
<itemQty>1</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>9A5030BE-F95F-4C62-B5A2-41FF85423218</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>4.0</itemPrice>
<itemQty>90</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>65A8B3BE-D407-43D8-8754-EA1E26AA56E4</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>0BDCB222-0117-47A9-8813-DF03A1D19E5E</orderId>
<ordertotal>925</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<orderId>8E4220DC-884B-47BC-A565-E26B80BA5249</orderId>
<ordertotal>0</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
<return>
<customerOrderNumber>1</customerOrderNumber>
<deliverydate>2013-02-06T00:00:00+05:30</deliverydate>
<orderDetails>
<itemPrice>10.0</itemPrice>
<itemQty>4</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>5A2DF895-BB0F-4039-80DB-F44CED31697B</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderDetails>
<itemPrice>20.0</itemPrice>
<itemQty>3</itemQty>
<itemUnit>0</itemUnit>
<orderDetailsId>8034FBF4-B573-4B19-BDF5-FAF6C4247A55</orderDetailsId>
<camelAddedDtlField>0.1</camelAddedDtlField>
</orderDetails>
<orderId>60161E3E-3C4A-4CE6-AAC3-E4D2BC240046</orderId>
<ordertotal>100</ordertotal>
<camelAddedHdrField>0.0</camelAddedHdrField>
</return>
</ns2:fetchOrderListResponse>
</soap:Body>
</soap:Envelope>
From the logs..(getting printed repeatedly..)
16:06:45,883 | ERROR | ExtenderThread-2 | XsltErrorListener | 147 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | A location step was expected following the '/' or '//' token.; Line#: 8; Column#: 78
javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:610)[:]
at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1639)[:]
at org.apache.xpath.compiler.XPathParser.LocationPath(XPathParser.java:1597)[:]
at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1317)[:]
at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1236)[:]
at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1142)[:]
at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1063)[:]
at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:1005)[:]
at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:930)[:]
at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:870)[:]
at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:834)[:]
at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:807)[:]
at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:790)[:]
at org.apache.xpath.compiler.XPathParser.Argument(XPathParser.java:1469)[:]
at org.apache.xpath.compiler.XPathParser.FunctionCall(XPathParser.java:1537)[:]
at org.apache.xpath.compiler.XPathParser.PrimaryExpr(XPathParser.java:1446)[:]
at org.apache.xpath.compiler.XPathParser.FilterExpr(XPathParser.java:1345)[:]
at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1278)[:]
at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1236)[:]
at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1142)[:]
at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1063)[:]
at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:1005)[:]
at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:930)[:]
at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:870)[:]
at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:834)[:]
at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:807)[:]
at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:790)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:129)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:157)[:]

Just in case, if with Karaf + Apache camel you are getting error for XSLT 2.0 such as one mentioned below, simply force camel xslt component to use saxon (camel-saxon) instead of default from the JDK.
This could also occur if you create new nodes in karaf 4.x+ and with root node same xslt component could work but new nodes will try to pick xslt processor from JDK.
Problem (Error Sample):
javax.xml.transform.TransformerConfigurationException: Error checking type of the expression 'funcall(current-dateTime, [])'.
Solution (Example):
<to uri="xslt:transformers/XSLT-Mappers/CustomerService-Response.xsl?saxon=true" />

Related

XSL looping is not occurring properly at each level

I need to loop though this SAP IDOC to report shipment data. I need to break at each change of E2EDT37_KDMAT (part number), E2EDT37_VHILM_KU (package type) and E2EDT37_QUANTITY in the G07 node (PACKAGE). The current code seemed to work until there was more than one G16 (DELIVERY) node within a G01 (SHIPMENT) node.
This snippet of code doesn't produce XML output and the issue is seen in the message output.
I believe the method I am trying is just not valid and I will find another way. But I don't understand why exactly. I've tried preceding-sibling instead of preceding and just got different wrong output.
Each loop uses the same predicate as the last with one more criterion added to identify all matching the E2EDT37 records and perform the next statement once for each unique value of E2EDT37_KDMAT, E2EDT37_VHILM_KU and lastly E2EDT37_QUANTITY. It seems to come so close but never gets it right. What is my misunderstanding of the way E2EDT37_KDMAT[not(.=preceding::E2EDT37_KDMAT)] works here?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.1" xmlns:exsl="http://exslt.org/common"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:XmlTransform="java:de.axway.converter.xml.xsltextensions.XsltExtensions" exclude-result-prefixes="XmlTransform xsl exsl">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/ACTIS">
<xsl:message></xsl:message>
<xsl:call-template name="DESADV_D96A"/>
</xsl:template>
<xsl:template name="DESADV_D96A">
<xsl:for-each select="//G16">
<xsl:variable name="current-delivery" select="E2EDL20/E2EDL20_VBELN "/>
<xsl:choose>
<xsl:when test="/ACTIS/G01/G07[#PACK_TYPE='OUTER']/E2EDT37[contains(E2EDT37_DELIVERIES, $current-delivery)]">
<xsl:call-template name="Create_Outer_PAC">
<xsl:with-param name="current-delivery" select=" $current-delivery "/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="Create_Outer_PAC">
<xsl:param name="current-delivery"/>
<xsl:message>In Create_Outer_PACK Delivery: <xsl:value-of select="$current-delivery"/></xsl:message>
<xsl:for-each select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='OUTER'][contains(E2EDT37_DELIVERIES, $current-delivery)]">
<xsl:variable name="Pallet" select="current()"/>
<xsl:message>For each Outer_PAC : <xsl:value-of select="$Pallet/E2EDT37_EXIDV"/></xsl:message>
<xsl:for-each select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery]/E2EDT37_KDMAT[not(.=preceding::E2EDT37_KDMAT)]">
<xsl:variable name="current-part" select="current()"/>
<xsl:message>For each E2EDT37_KDMAT : <xsl:value-of select="$current-part"/></xsl:message>
<xsl:message select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery][E2EDT37_KDMAT=$current-part]/E2EDT37_VHILM_KU"/>
<xsl:for-each select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery][E2EDT37_KDMAT=$current-part]/E2EDT37_VHILM_KU[not(.=preceding::E2EDT37_VHILM_KU)]">
<xsl:variable name="current-vhilm_ku" select="current()"/>
<xsl:message>For each E2EDT37_VHILM_KU: <xsl:value-of select="$current-vhilm_ku"/></xsl:message>
<xsl:for-each select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery][E2EDT37_KDMAT=$current-part][E2EDT37_VHILM_KU=$current-vhilm_ku]/E2EDT37_QUANTITY[not(.=preceding::E2EDT37_QUANTITY)]">
<xsl:variable name="current-packqty" select="current()"/>
<xsl:message></xsl:message>
<xsl:message>For each E2EDT37_QUANTITY: <xsl:value-of select="$current-packqty"/></xsl:message>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Data
<?xml version="1.0" encoding="UTF-8"?>
<ACTIS>
<EDI_DC>
<EDI_DC_TABNAM>EDI_DC40</EDI_DC_TABNAM>
<EDI_DC_CREDAT>20190702</EDI_DC_CREDAT>
<EDI_DC_CRETIM>210325</EDI_DC_CRETIM>
<EDI_DC_SERIAL>20190702210323</EDI_DC_SERIAL>
</EDI_DC>
<G01>
<E2EDT20>
<E2EDT20_SEGNAM>E2EDT20002</E2EDT20_SEGNAM>
<E2EDT20_MANDT>100</E2EDT20_MANDT>
<E2EDT20_DOCNUM>0000004250699555</E2EDT20_DOCNUM>
<E2EDT20_SEGNUM>000001</E2EDT20_SEGNUM>
<E2EDT20_PSGNUM>000000</E2EDT20_PSGNUM>
<E2EDT20_HLEVEL>01</E2EDT20_HLEVEL>
<E2EDT20_TKNUM>0049409223</E2EDT20_TKNUM>
</E2EDT20>
<G07 PACK_TYPE="INNER" PARENT="505059227" CHILDREN="0" MIXED="0">
<E2EDT37 PACK_TYPE="INNER" PARENT="505059227" CHILDREN="0" MIXED="0">
<E2EDT37_SEGNAM>E2EDT37006</E2EDT37_SEGNAM>
<E2EDT37_MANDT>100</E2EDT37_MANDT>
<E2EDT37_DOCNUM>0000004250699555</E2EDT37_DOCNUM>
<E2EDT37_SEGNUM>000044</E2EDT37_SEGNUM>
<E2EDT37_PSGNUM>000001</E2EDT37_PSGNUM>
<E2EDT37_HLEVEL>02</E2EDT37_HLEVEL>
<E2EDT37_EXIDV>00000000000505755236</E2EDT37_EXIDV>
<E2EDT37_VHILM_KU>0000SON</E2EDT37_VHILM_KU>
<E2EDT37_PACK_TYPE>INNER</E2EDT37_PACK_TYPE>
<E2EDT37_CHILDREN>0</E2EDT37_CHILDREN>
<E2EDT37_PARENT>505059227</E2EDT37_PARENT>
<E2EDT37_DELIVERY>0037371519</E2EDT37_DELIVERY>
<E2EDT37_DELIVERY_POSITION>000010</E2EDT37_DELIVERY_POSITION>
<E2EDT37_QUANTITY>8500.000</E2EDT37_QUANTITY>
<E2EDT37_UOM>PCE</E2EDT37_UOM>
<E2EDT37_KDMAT>6561111</E2EDT37_KDMAT>
<E2EDT37_VBRST>1000</E2EDT37_VBRST>
</E2EDT37>
</G07>
<G07 PACK_TYPE="INNER" PARENT="505059227" CHILDREN="0" MIXED="0">
<E2EDT37 PACK_TYPE="INNER" PARENT="505059227" CHILDREN="0" MIXED="0">
<E2EDT37_SEGNAM>E2EDT37006</E2EDT37_SEGNAM>
<E2EDT37_MANDT>100</E2EDT37_MANDT>
<E2EDT37_DOCNUM>0000004250699555</E2EDT37_DOCNUM>
<E2EDT37_SEGNUM>000047</E2EDT37_SEGNUM>
<E2EDT37_PSGNUM>000001</E2EDT37_PSGNUM>
<E2EDT37_HLEVEL>02</E2EDT37_HLEVEL>
<E2EDT37_EXIDV>00000000000505755237</E2EDT37_EXIDV>
<E2EDT37_VHILM_KU>0000SON</E2EDT37_VHILM_KU>
<E2EDT37_PACK_TYPE>INNER</E2EDT37_PACK_TYPE>
<E2EDT37_CHILDREN>0</E2EDT37_CHILDREN>
<E2EDT37_PARENT>505059227</E2EDT37_PARENT>
<E2EDT37_DELIVERY>0037371484</E2EDT37_DELIVERY>
<E2EDT37_DELIVERY_POSITION>000010</E2EDT37_DELIVERY_POSITION>
<E2EDT37_QUANTITY>7000.000</E2EDT37_QUANTITY>
<E2EDT37_UOM>PCE</E2EDT37_UOM>
<E2EDT37_KDMAT>6561143</E2EDT37_KDMAT>
<E2EDT37_VBRST>1000</E2EDT37_VBRST>
</E2EDT37>
</G07>
<G07 PACK_TYPE="OUTER" CHILDREN="2" MIXED="1">
<E2EDT37 PACK_TYPE="OUTER" CHILDREN="2" MIXED="1">
<E2EDT37_SEGNAM>E2EDT37006</E2EDT37_SEGNAM>
<E2EDT37_MANDT>100</E2EDT37_MANDT>
<E2EDT37_DOCNUM>0000004250699555</E2EDT37_DOCNUM>
<E2EDT37_SEGNUM>000050</E2EDT37_SEGNUM>
<E2EDT37_PSGNUM>000001</E2EDT37_PSGNUM>
<E2EDT37_HLEVEL>02</E2EDT37_HLEVEL>
<E2EDT37_EXIDV>505059227</E2EDT37_EXIDV>
<E2EDT37_VHILM_KU>0000SON</E2EDT37_VHILM_KU>
<E2EDT37_CHILDREN>2</E2EDT37_CHILDREN>
<E2EDT37_CONTENTS>00000000000505755236:00000000000505755237:</E2EDT37_CONTENTS>
<E2EDT37_PACK_TYPE>OUTER</E2EDT37_PACK_TYPE>
<E2EDT37_DELIVERIES>0037371519 0037371484</E2EDT37_DELIVERIES>
</E2EDT37>
</G07>
<G16>
<E2EDL20>
<E2EDL20_SEGNAM>E2EDL20004</E2EDL20_SEGNAM>
<E2EDL20_MANDT>100</E2EDL20_MANDT>
<E2EDL20_DOCNUM>0000004250699555</E2EDL20_DOCNUM>
<E2EDL20_SEGNUM>000077</E2EDL20_SEGNUM>
<E2EDL20_PSGNUM>000001</E2EDL20_PSGNUM>
<E2EDL20_HLEVEL>02</E2EDL20_HLEVEL>
<E2EDL20_VBELN>0037371484</E2EDL20_VBELN>
<E2EDL20_VSTEL>0016</E2EDL20_VSTEL>
<E2EDL20_VKORG>0060</E2EDL20_VKORG>
<E2EDL20_VKBUR>EUR</E2EDL20_VKBUR>
<E2EDL20_LGNUM>D16</E2EDL20_LGNUM>
<E2EDL20_ABLAD>JAG01</E2EDL20_ABLAD>
<E2EDL20_INCO1>FCA</E2EDL20_INCO1>
<E2EDL20_INCO2>NÜRNBERG</E2EDL20_INCO2>
<E2EDL20_ROUTE>DES129</E2EDL20_ROUTE>
<E2EDL20_VSBED>ST</E2EDL20_VSBED>
<E2EDL20_BTGEW>107.000</E2EDL20_BTGEW>
<E2EDL20_NTGEW>107.000</E2EDL20_NTGEW>
<E2EDL20_GEWEI>KGM</E2EDL20_GEWEI>
<E2EDL20_VOLUM>1036.427</E2EDL20_VOLUM>
<E2EDL20_VOLEH>DMQ</E2EDL20_VOLEH>
<E2EDL20_ANZPK>00000</E2EDL20_ANZPK>
<E2EDL20_PARID>UNKNOWN</E2EDL20_PARID>
<E2EDL20_PODAT>20190702</E2EDL20_PODAT>
<E2EDL20_POTIM>210324</E2EDL20_POTIM>
</E2EDL20>
<G29>
<E2EDL24>
<E2EDL24_POSNR>000010</E2EDL24_POSNR>
<E2EDL24_KDMAT>6561143</E2EDL24_KDMAT>
<E2EDL24_LFIMG>7000.000</E2EDL24_LFIMG>
<E2EDL24_VRKME>PCE</E2EDL24_VRKME>
<E2EDL24_VBRST>1000</E2EDL24_VBRST>
<E2EDL24_KDMAT35>6561143</E2EDL24_KDMAT35>
<E2EDL24_POSEX>000000</E2EDL24_POSEX>
<E2EDL24_DELIVERY>0037371484</E2EDL24_DELIVERY>
<E2EDL24_PO>5500229851</E2EDL24_PO>
<E2EDL24_PO_DATE>20150612</E2EDL24_PO_DATE>
</E2EDL24>
</G29>
<G29>
<E2EDL24>
<E2EDL24_POSNR>900001</E2EDL24_POSNR>
<E2EDL24_KDMAT>0000SON</E2EDL24_KDMAT>
<E2EDL24_LFIMG>1.000</E2EDL24_LFIMG>
<E2EDL24_VRKME>PCE</E2EDL24_VRKME>
<E2EDL24_VBRST>1000</E2EDL24_VBRST>
<E2EDL24_KDMAT35>0000SON</E2EDL24_KDMAT35>
<E2EDL24_POSEX>000000</E2EDL24_POSEX>
<E2EDL24_DELIVERY>0037371484</E2EDL24_DELIVERY>
</E2EDL24>
</G29>
</G16>
<G16>
<E2EDL20>
<E2EDL20_SEGNAM>E2EDL20004</E2EDL20_SEGNAM>
<E2EDL20_MANDT>100</E2EDL20_MANDT>
<E2EDL20_DOCNUM>0000004250699555</E2EDL20_DOCNUM>
<E2EDL20_SEGNUM>000170</E2EDL20_SEGNUM>
<E2EDL20_PSGNUM>000001</E2EDL20_PSGNUM>
<E2EDL20_HLEVEL>02</E2EDL20_HLEVEL>
<E2EDL20_VBELN>0037371519</E2EDL20_VBELN>
<E2EDL20_VSTEL>0016</E2EDL20_VSTEL>
<E2EDL20_VKORG>0060</E2EDL20_VKORG>
<E2EDL20_VKBUR>EUR</E2EDL20_VKBUR>
<E2EDL20_LGNUM>D16</E2EDL20_LGNUM>
<E2EDL20_ABLAD>JAG01</E2EDL20_ABLAD>
<E2EDL20_INCO1>FCA</E2EDL20_INCO1>
<E2EDL20_INCO2>NÜRNBERG</E2EDL20_INCO2>
<E2EDL20_ROUTE>DES129</E2EDL20_ROUTE>
<E2EDL20_VSBED>ST</E2EDL20_VSBED>
<E2EDL20_BTGEW>140.600</E2EDL20_BTGEW>
<E2EDL20_NTGEW>127.500</E2EDL20_NTGEW>
<E2EDL20_GEWEI>KGM</E2EDL20_GEWEI>
<E2EDL20_VOLUM>42840.000</E2EDL20_VOLUM>
<E2EDL20_VOLEH>CMQ</E2EDL20_VOLEH>
<E2EDL20_ANZPK>00000</E2EDL20_ANZPK>
<E2EDL20_PARID>UNKNOWN</E2EDL20_PARID>
<E2EDL20_PODAT>20190702</E2EDL20_PODAT>
<E2EDL20_POTIM>210325</E2EDL20_POTIM>
</E2EDL20>
<G29>
<E2EDL24>
<E2EDL24_POSNR>000010</E2EDL24_POSNR>
<E2EDL24_KDMAT>6561111</E2EDL24_KDMAT>
<E2EDL24_LFIMG>8500.000</E2EDL24_LFIMG>
<E2EDL24_VRKME>PCE</E2EDL24_VRKME>
<E2EDL24_VBRST>1000</E2EDL24_VBRST>
<E2EDL24_KDMAT35>6561111</E2EDL24_KDMAT35>
<E2EDL24_POSEX>000000</E2EDL24_POSEX>
<E2EDL24_DELIVERY>0037371519</E2EDL24_DELIVERY>
<E2EDL24_PO>5500229848</E2EDL24_PO>
<E2EDL24_PO_DATE>20150612</E2EDL24_PO_DATE>
</E2EDL24>
</G29>
</G16>
</G01>
</ACTIS>
Resulting Output
1) In Create_Outer_PAC Delivery : 0037371484
2) For each Outer_PAC : 505059227
3) For each E2EDT37_KDMAT : 6561143 Good break here at unique KDMAT
I find and display a single matching VHILM_KU here but the next line that tries to loop at each VHILM_KU doesn't occur with the same Xpath as the xsl:message
<xsl:for-each select="/ACTIS/G01/G07/E2EDT37[E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery][E2EDT37_KDMAT=$current-part]/E2EDT37_VHILM_KU[not(.=preceding::E2EDT37_VHILM_KU)]">
<E2EDT37_VHILM_KU>0000SON</E2EDT37_VHILM_KU>
No For each E2EDT37_VHILM_KU break on E2EDT37_VHILM_KU=0000SON
1) In Create_Outer_PAC Delivery : 0037371519
2) For each Outer_PAC : 505059227
3) For each E2EDT37_KDMAT : 6561111
<E2EDT37_VHILM_KU>0000SON</E2EDT37_VHILM_KU>
This one breaks as expected. You see we have an E2EDT37_VHILM_KU found with value 0000SON in the line above here.
I don't reach this message in the first for-each loop above although we also find and display the same E2EDT37_VHILM_KU of 0000SON.
We have two E2EDT37 segments with KDMAT values of 6561143 and 6561141. The first loop breaks at each unique KDMAT as expected.
4) For each E2EDT37_VHILM_KU : 0000SON
5) For each E2EDT37_QUANTITY : 8500.000
Is it valid to check for unique values with /E2EDT37_VHILM_KU[not(.=preceding::E2EDT37_VHILM_KU)] at the same time as limiting the resulting nodes with the predicates [E2EDT37_PACK_TYPE='INNER'][E2EDT37_PARENT=$Pallet/E2EDT37_EXIDV][E2EDT37_DELIVERY=$current-delivery][E2EDT37_KDMAT=$current-part]? I assume that's where I am wrong but the paradigm is not clear to me. The message output shows me the Xpath did find a single VHILM_KU. The next for-each statement with the same Xpath finds nothing.
Is that clearer or more confusing?

use first three digits of string to loop and group elements in output

In the following xml the first three digits of "number"can be used to group "number" elements in resulted output. However I have no Idea how ?
Please see the input XML and my desired output bellow
Input
[see the input and the desired output][1]
<data>
<InputElemenmts>
<Element11>
<key>73004</key>
<number>001001</number>
</Element11>
<Element11>
<key>7300465</key>
<number>002001</number>
</Element11>
<Element11>
<key>730046</key>
<number>003001</number>
</Element11>
<Element11>
<key>730046</key>
<number>003002</number>
</Element11>
<Element11>
<key>730046</key>
<number>003003</number>
</Element11>
<Element11>
<key>730049</key>
<number>004001</number>
</Element11>
<Element11>
<key>730046</key>
<number>005001</number>
</Element11>
<Element11>
<key>730040</key>
<number>006001</number>
</Element11>
<Element11>
<key>730040</key>
<number>006002</number>
</Element11>
<Element11>
<key>730041</key>
<number>007001</number>
</Element11>
<Element11>
<key>730042</key>
<number>008001</number>
</Element11>
</InputElemenmts>
<OutputElemenmts>
<result>
<key>7300462</key>
<number>001001</number>
</result>
<result>
<key>7300465</key>
<number>002001</number>
</result>
<result>
<key>73004</key>
<Element>
<number>003001</number>
<number>003002</number>
<number>003003</number>
</Element>
</result>
<result>
<key>730049</key>
<number>004001</number>
</result>
<result>
<key>730046</key>
<number>005001</number>
</result>
<result>
<key>730040</key>
<Element>
<number>006001</number>
<number>006002</number>
</Element>
</result>
<result>
<key>730041</key>
<number>007001</number>
</result>
<result>
<key>730042</key>
<number>008001</number>
</result>
</OutputElemenmts>
This is what I've understood but probably not what you wanted??
<!-- find the last of Element11 with any key -->
<xsl:template match="Element11[not(following::Element11[key = current()/key])]">
<result>
<key><xsl:value-of select="key"/></key>
<xsl:choose>
<!-- are there more than one with this key? -->
<xsl:when test="preceding-sibling::Element11[key = current()/key]">
<!-- if yes it seems you want an Element wrapper -->
<Element>
<xsl:for-each select="preceding-sibling::Element11[key = current()/key]/number">
<number><xsl:value-of select="."/></number>
</xsl:for-each>
<!-- the current one -->
<number><xsl:value-of select="number"/></number>
</Element>
</xsl:when>
<xsl:otherwise>
<!-- only the current one -->
<number><xsl:value-of select="number"/></number>
</xsl:otherwise>
</xsl:choose>
</result>
</xsl:template>
<xsl:template match="Element11"/>

read Xml into ms sql

I want to read the xml pasted below into sql. I tried several ways from the web to parse this xml without success.
I tried the following script:
CREATE TABLE [dbo].[Ejemplo2](
[RutEmisor][nvarchar](12) null,
[RutEnvia][nvarchar](12) null,
[RutReceptor][nvarchar](12) null,
[FchResol][nvarchar](12) null,
[NroResol][nvarchar](12) null
)
GO
DECLARE #messagebody XML
SELECT #messagebody = BulkColumn
FROM OPENROWSET(BULK 'C:\Ejemplo.xml', SINGLE_CLOB) AS X
INSERT INTO [dbo].[Ejemplo2]
select a.value(N'(./RutEmisor)[1]', N'nvarchar(12)') as [RutEmisor],
a.value(N'(./RutEnvia)[1]', N'nvarchar(12)') as [RutEnvia],
a.value(N'(./RutReceptor)[1]', N'nvarchar(12)') as [RutReceptor],
a.value(N'(./FchResol)[1]', N'nvarchar(12)') as [FchResol],
a.value(N'(./NroResol)[1]', N'nvarchar(12)') as [NroResol]
from #messagebody.nodes('/EnvioDTE/SetDTE/Caratula') as r(a);
Select * from dbo.Ejemplo2
But I get 0 rows
I tried with more simple examples and always return the data, but in this case I can't figure whats is wrong.
Any help on this will be appreciated.
The xml follows
<?xml version="1.0" encoding="ISO-8859-1"?>
<EnvioDTE xmlns="http://www.sii.cl/SiiDte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sii.cl/SiiDte EnvioDTE_v10.xsd" version="1.0">
<SetDTE ID="SetDoc">
<TmstFirmaEnv>2003-10-13T09:33:22</TmstFirmaEnv>
<Caratula version="1.0">
<RutEmisor>97975000-5</RutEmisor>
<RutEnvia>7880442-4</RutEnvia>
<RutReceptor>60803000-K</RutReceptor>
<FchResol>2003-09-02</FchResol>
<NroResol>0</NroResol>
<SubTotDTE>
<TpoDTE>33</TpoDTE>
<NroDTE>1</NroDTE>
</SubTotDTE>
</Caratula>
<DTE version="1.0">
<Documento ID="F60T33">
<Encabezado>
<IdDoc>
<TipoDTE>33</TipoDTE>
<Folio>60</Folio>
<FchEmis>2003-10-13</FchEmis>
</IdDoc>
<Emisor>
<RUTEmisor>97975000-5</RUTEmisor>
<RznSoc>RUT DE PRUEBA</RznSoc>
<GiroEmis>Insumos de Computacion</GiroEmis>
<Acteco>31341</Acteco>
<CdgSIISucur>1234</CdgSIISucur>
<DirOrigen>Teatinos 120, Piso 4</DirOrigen>
<CmnaOrigen>Santiago</CmnaOrigen>
<CiudadOrigen>Santiago</CiudadOrigen>
</Emisor>
<Receptor>
<RUTRecep>77777777-7</RUTRecep>
<RznSocRecep>EMPRESA LTDA</RznSocRecep>
<GiroRecep>COMPUTACION</GiroRecep>
<DirRecep>SAN DIEGO 2222</DirRecep>
<CmnaRecep>LA FLORIDA</CmnaRecep>
<CiudadRecep>SANTIAGO</CiudadRecep>
</Receptor>
<Totales>
<MntNeto>100000</MntNeto>
<TasaIVA>19</TasaIVA>
<IVA>19000</IVA>
<MntTotal>119000</MntTotal>
</Totales>
</Encabezado>
<Detalle>
<NroLinDet>1</NroLinDet>
<CdgItem>
<TpoCodigo>INT1</TpoCodigo>
<VlrCodigo>011</VlrCodigo>
</CdgItem>
<NmbItem>Parlantes Multimedia 180W.</NmbItem>
<DscItem/>
<QtyItem>20</QtyItem>
<PrcItem>4500</PrcItem>
<MontoItem>90000</MontoItem>
</Detalle>
<Detalle>
<NroLinDet>2</NroLinDet>
<CdgItem>
<TpoCodigo>INT1</TpoCodigo>
<VlrCodigo>0231</VlrCodigo>
</CdgItem>
<NmbItem>Mouse Inalambrico PS/2</NmbItem>
<DscItem/>
<QtyItem>1</QtyItem>
<PrcItem>5000</PrcItem>
<MontoItem>5000</MontoItem>
</Detalle>
<Detalle>
<NroLinDet>3</NroLinDet>
<CdgItem>
<TpoCodigo>INT1</TpoCodigo>
<VlrCodigo>1515</VlrCodigo>
</CdgItem>
<NmbItem>Caja de Diskettes 10 Unidades</NmbItem>
<DscItem/>
<QtyItem>5</QtyItem>
<PrcItem>1000</PrcItem>
<MontoItem>5000</MontoItem>
</Detalle>
<TED version="1.0">
<DD>
<RE>97975000-5</RE>
<TD>33</TD>
<F>60</F>
<FE>2003-10-13</FE>
<RR>77777777-7</RR>
<RSR>EMPRESA LTDA</RSR>
<MNT>119000</MNT>
<IT1>Parlantes Multimedia 180W.</IT1>
<CAF version="1.0">
<DA>
<RE>97975000-5</RE>
<RS>RUT DE PRUEBA</RS>
<TD>33</TD>
<RNG>
<D>1</D>
<H>200</H>
</RNG>
<FA>2003-09-04</FA>
<RSAPK>
<M>0a4O6Kbx8Qj3K4iWSP4w7KneZYeJ+g/prihYtIEolKt3cykSxl1zO8vSXu397QhTmsX7SBEudTUx++2zDXBhZw==</M>
<E>Aw==</E>
</RSAPK>
<IDK>100</IDK>
</DA>
<FRMA algoritmo="SHA1withRSA">g1AQX0sy8NJugX52k2hTJEZAE9Cuul6pqYBdFxj1N17umW7zG/hAavCALKByHzdYAfZ3LhGTXCai5zNxOo4lDQ==</FRMA>
</CAF>
<TSTED>2003-10-13T09:33:20</TSTED>
</DD>
<FRMT algoritmo="SHA1withRSA">GbmDcS9e/jVC2LsLIe1iRV12Bf6lxsILtbQiCkh6mbjckFCJ7fj/kakFTS06Jo8i
S4HXvJj3oYZuey53Krniew==</FRMT>
</TED>
<TmstFirma>2003-10-13T09:33:20</TmstFirma>
</Documento>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#F60T33">
<Transforms>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>hlmQtu/AyjUjTDhM3852wvRCr8w=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>JG1Ig0pvSIH85kIKGRZUjkyX6CNaY08Y94j4UegTgDe8+wl61GzqjdR1rfOK9BGn93AMOo6aiAgolW0k/XklNVtM/ZzpNNS3d/fYVa1q509mAMSXbelxSM3bjoa7H6Wzd/mV1PpQ8zK5gw7mgMMP4IKxHyS92G81GEguSmzcQmA=</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus>
tNEknkb1kHiD1OOAWlLKkcH/UP5UGa6V6MYso++JB+vYMg2OXFROAF7G8BNFFPQx
iuS/7y1azZljN2xq+bW3bAou1bW2ij7fxSXWTJYFZMAyndbLyGHM1e3nVmwpgEpx
BHhZzPvwLb55st1wceuKjs2Ontb13J33sUb7bbJMWh0=
</Modulus>
<Exponent>
AQAB
</Exponent>
</RSAKeyValue>
</KeyValue>
<X509Data>
<X509Certificate>MIIEgjCCA+ugAwIBAgIEAQAApzANBgkqhkiG9w0BAQUFADCBtTELMAkGA1UEBhMC
Q0wxHTAbBgNVBAgUFFJlZ2lvbiBNZXRyb3BvbGl0YW5hMREwDwYDVQQHFAhTYW50
aWFnbzEUMBIGA1UEChQLRS1DRVJUQ0hJTEUxIDAeBgNVBAsUF0F1dG9yaWRhZCBD
ZXJ0aWZpY2Fkb3JhMRcwFQYDVQQDFA5FLUNFUlRDSElMRSBDQTEjMCEGCSqGSIb3
DQEJARYUZW1haWxAZS1jZXJ0Y2hpbGUuY2wwHhcNMDMxMDAxMTg1ODE1WhcNMDQw
OTMwMDAwMDAwWjCBuDELMAkGA1UEBhMCQ0wxFjAUBgNVBAgUDU1ldHJvcG9saXRh
bmExETAPBgNVBAcUCFNhbnRpYWdvMScwJQYDVQQKFB5TZXJ2aWNpbyBkZSBJbXB1
ZXN0b3MgSW50ZXJub3MxDzANBgNVBAsUBlBpc28gNDEjMCEGA1UEAxQaV2lsaWJh
bGRvIEdvbnphbGV6IENhYnJlcmExHzAdBgkqhkiG9w0BCQEWEHdnb256YWxlekBz
aWkuY2wwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALxZlVh1xr9sKQIBDF/6
Va+lsHQSG5AAmCWvtNTIOXN3E9EQCy7pOPHrDg6EusvoHyesZSKJbc0TnIFXZp78
q7mbdHijzKqvMmyvwbdP7KK8LQfwf84W4v9O8MJeUHlbJGlo5nFACrPAeTtONbHa
ReyzeMDv2EganNEDJc9c+UNfAgMBAAGjggGYMIIBlDAjBgNVHREEHDAaoBgGCCsG
AQQBwQEBoAwWCjA3ODgwNDQyLTQwCQYDVR0TBAIwADA8BgNVHR8ENTAzMDGgL6At
hitodHRwOi8vY3JsLmUtY2VydGNoaWxlLmNsL2UtY2VydGNoaWxlY2EuY3JsMCMG
A1UdEgQcMBqgGAYIKwYBBAHBAQKgDBYKOTY5MjgxODAtNTAfBgNVHSMEGDAWgBTg
KP3S4GBPs0brGsz1CJEHcjodCDCB0AYDVR0gBIHIMIHFMIHCBggrBgEEAcNSBTCB
tTAvBggrBgEFBQcCARYjaHR0cDovL3d3dy5lLWNlcnRjaGlsZS5jbC8yMDAwL0NQ
Uy8wgYEGCCsGAQUFBwICMHUac0VsIHRpdHVsYXIgaGEgc2lkbyB2YWxpZG8gZW4g
Zm9ybWEgcHJlc2VuY2lhbCwgcXVlZGFuZG8gZWwgQ2VydGlmaWNhZG8gcGFyYSB1
c28gdHJpYnV0YXJpbywgcGFnb3MsIGNvbWVyY2lvIHkgb3Ryb3MwCwYDVR0PBAQD
AgTwMA0GCSqGSIb3DQEBBQUAA4GBABMfCyJF0mNXcov8iEWvjGFyyPTsXwvsYbbk
OJ41wjaGOFMCInb4WY0ngM8BsDV22bGMs8oLyX7rVy16bGA8Z7WDUtYhoOM7mqXw
/Hrpqjh3JgAf8zqdzBdH/q6mAbdvq/yb04JHKWPC7fMFuBoeyVWAnhmuMZfReWQi
MUEHGGIW</X509Certificate>
</X509Data>
</KeyInfo>
</Signature></DTE>
</SetDTE><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#SetDoc">
<Transforms>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>4OTWXyRl5fw3htjTyZXQtYEsC3E=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>sBnr8Yq14vVAcrN/pKLD/BrqUFczKMW3y1t3JOrdsxhhq6IxvS13SgyMXbIN/T9ciRaFgNabs3pi732XhcpeiSmD1ktzbRctEbSIszYkFJY49k0eB+TVzq3eVaQr4INrymfuOnWj78BZcwKuXvDy4iAcx6/TBbAAkPFwMP9ql2s=</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus>
tNEknkb1kHiD1OOAWlLKkcH/UP5UGa6V6MYso++JB+vYMg2OXFROAF7G8BNFFPQx
iuS/7y1azZljN2xq+bW3bAou1bW2ij7fxSXWTJYFZMAyndbLyGHM1e3nVmwpgEpx
BHhZzPvwLb55st1wceuKjs2Ontb13J33sUb7bbJMWh0=
</Modulus>
<Exponent>
AQAB
</Exponent>
</RSAKeyValue>
</KeyValue>
<X509Data>
<X509Certificate>MIIEgjCCA+ugAwIBAgIEAQAApzANBgkqhkiG9w0BAQUFADCBtTELMAkGA1UEBhMC
Q0wxHTAbBgNVBAgUFFJlZ2lvbiBNZXRyb3BvbGl0YW5hMREwDwYDVQQHFAhTYW50
aWFnbzEUMBIGA1UEChQLRS1DRVJUQ0hJTEUxIDAeBgNVBAsUF0F1dG9yaWRhZCBD
ZXJ0aWZpY2Fkb3JhMRcwFQYDVQQDFA5FLUNFUlRDSElMRSBDQTEjMCEGCSqGSIb3
DQEJARYUZW1haWxAZS1jZXJ0Y2hpbGUuY2wwHhcNMDMxMDAxMTg1ODE1WhcNMDQw
OTMwMDAwMDAwWjCBuDELMAkGA1UEBhMCQ0wxFjAUBgNVBAgUDU1ldHJvcG9saXRh
bmExETAPBgNVBAcUCFNhbnRpYWdvMScwJQYDVQQKFB5TZXJ2aWNpbyBkZSBJbXB1
ZXN0b3MgSW50ZXJub3MxDzANBgNVBAsUBlBpc28gNDEjMCEGA1UEAxQaV2lsaWJh
bGRvIEdvbnphbGV6IENhYnJlcmExHzAdBgkqhkiG9w0BCQEWEHdnb256YWxlekBz
aWkuY2wwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALxZlVh1xr9sKQIBDF/6
Va+lsHQSG5AAmCWvtNTIOXN3E9EQCy7pOPHrDg6EusvoHyesZSKJbc0TnIFXZp78
q7mbdHijzKqvMmyvwbdP7KK8LQfwf84W4v9O8MJeUHlbJGlo5nFACrPAeTtONbHa
ReyzeMDv2EganNEDJc9c+UNfAgMBAAGjggGYMIIBlDAjBgNVHREEHDAaoBgGCCsG
AQQBwQEBoAwWCjA3ODgwNDQyLTQwCQYDVR0TBAIwADA8BgNVHR8ENTAzMDGgL6At
hitodHRwOi8vY3JsLmUtY2VydGNoaWxlLmNsL2UtY2VydGNoaWxlY2EuY3JsMCMG
A1UdEgQcMBqgGAYIKwYBBAHBAQKgDBYKOTY5MjgxODAtNTAfBgNVHSMEGDAWgBTg
KP3S4GBPs0brGsz1CJEHcjodCDCB0AYDVR0gBIHIMIHFMIHCBggrBgEEAcNSBTCB
tTAvBggrBgEFBQcCARYjaHR0cDovL3d3dy5lLWNlcnRjaGlsZS5jbC8yMDAwL0NQ
Uy8wgYEGCCsGAQUFBwICMHUac0VsIHRpdHVsYXIgaGEgc2lkbyB2YWxpZG8gZW4g
Zm9ybWEgcHJlc2VuY2lhbCwgcXVlZGFuZG8gZWwgQ2VydGlmaWNhZG8gcGFyYSB1
c28gdHJpYnV0YXJpbywgcGFnb3MsIGNvbWVyY2lvIHkgb3Ryb3MwCwYDVR0PBAQD
AgTwMA0GCSqGSIb3DQEBBQUAA4GBABMfCyJF0mNXcov8iEWvjGFyyPTsXwvsYbbk
OJ41wjaGOFMCInb4WY0ngM8BsDV22bGMs8oLyX7rVy16bGA8Z7WDUtYhoOM7mqXw
/Hrpqjh3JgAf8zqdzBdH/q6mAbdvq/yb04JHKWPC7fMFuBoeyVWAnhmuMZfReWQi
MUEHGGIW</X509Certificate>
</X509Data>
</KeyInfo>
</Signature></EnvioDTE>
This Works. You add "*:" for the nodes.
DECLARE #messagebody XML
SELECT #messagebody = BulkColumn
FROM OPENROWSET(BULK 'C:\Ejemplo.xml', SINGLE_CLOB) AS X
PRINT CONVERT(VARCHAR(MAX),#messagebody)
INSERT INTO [dbo].[Ejemplo24]
select a.value(N'(./*:RutEmisor)[1]', N'nvarchar(12)') as [RutEmisor],
a.value(N'(./*:RutEnvia)[1]', N'nvarchar(12)') as [RutEnvia],
a.value(N'(./*:RutReceptor)[1]', N'nvarchar(12)') as [RutReceptor],
a.value(N'(./*:FchResol)[1]', N'nvarchar(12)') as [FchResol],
a.value(N'(./*:NroResol)[1]', N'nvarchar(12)') as [NroResol]
from #messagebody.nodes('/*:EnvioDTE/*:SetDTE/*:Caratula') as r(a);
Your query is great, but you must specify the default namespace xmlns
Try like this:
WITH XMLNAMESPACES(DEFAULT 'http://www.sii.cl/SiiDte')
INSERT INTO [dbo].[Ejemplo2]
select a.value(N'(./RutEmisor)[1]', N'nvarchar(12)') as [RutEmisor],
a.value(N'(./RutEnvia)[1]', N'nvarchar(12)') as [RutEnvia],
a.value(N'(./RutReceptor)[1]', N'nvarchar(12)') as [RutReceptor],
a.value(N'(./FchResol)[1]', N'nvarchar(12)') as [FchResol],
a.value(N'(./NroResol)[1]', N'nvarchar(12)') as [NroResol]
from #messagebody.nodes('/EnvioDTE/SetDTE/Caratula') as r(a);

XML XPath - Sub path

Using the following XML, in SQL Server how can I get a table of LineItemId,PetId(value),vetid(Value)? I'm stumped.
Basically, It should return:
255fa32c-dce6-4e7a-83a5-4b45f22f00fc 75866 12916
183dc279-53a6-45fc-9e75-57770582b6bc 34535 34546
From this XML:
<PurchaseOrder>
<OrderForms>
<OrderForm>
<LineItems>
<LineItem LineItemId="255fa32c-dce6-4e7a-83a5-4b45f22f00fc">
<WeaklyTypedProperties>
<WeaklyTypedProperty Name="petId" Value="75866" Type="String" />
<WeaklyTypedProperty Name="vetId" Value="12916" Type="String" />
</WeaklyTypedProperties>
</LineItem>
<LineItem LineItemId="183dc279-53a6-45fc-9e75-57770582b6bc">
<WeaklyTypedProperties>
<WeaklyTypedProperty Name="petId" Value="345345" Type="String" />
<WeaklyTypedProperty Name="vetId" Value="345346" Type="String" />
</WeaklyTypedProperties>
</LineItem>
</LineItems>
</OrderForm>
</OrderForms>
</PurchaseOrder>
I should state I have tried the following, but it gives blanks for petId and vetId:
SELECT
p.value('#LineItemId','NVARCHAR(100)')
,p.query('//PurchaseOrder/OrderForms/OrderForm[1]/LineItems/LineItem[1]/WeaklyTypedProperties/WeaklyTypedProperty[Name="petId"]')
,p.query('//PurchaseOrder/OrderForms/OrderForm[1]/LineItems/LineItem[1]/WeaklyTypedProperties/WeaklyTypedProperty[Name="vetid"]')
FROM
dbo.[PurchaseOrdersMarshalledData] pomd
CROSS APPLY pomd.[MarshalledData].nodes('//PurchaseOrder/OrderForms/OrderForm[1]/LineItems/LineItem') x(p)
Thanks!
SELECT
[LineItemId] = l.value('#LineItemId', 'nvarchar(100)'),
[PetId] = w.value('WeaklyTypedProperty[#Name="petId"][1]/#Value', 'int'),
[VetId] = w.value('WeaklyTypedProperty[#Name="vetId"][1]/#Value', 'int')
FROM dbo.[PurchaseOrdersMarshalledData] pomp
CROSS APPLY pomp.[MarshalledData].nodes('//PurchaseOrder/OrderForms/OrderForm[1]/LineItems/LineItem') LineItem(l)
CROSS APPLY l.nodes('WeaklyTypedProperties') WeaklyTypedProperty(w)
Haven't tried it... maybe the syntaxis is not 100% correct...
<xsl:for-each select="/PurcharseOrder/OrderForms/OrderForm/LineItems/LineItem"/>
<xsl:value-of select="#LineItemId"/>
<xsl:for-each select="WeaklyTypedProperties"/>
<xsl:value-of select="WeaklyTypedProperty/#Value"/>
</xsl:for-each>
</xsl:for-each>

xsl iterate through list of alphabet

I need to iterate through the alphabet a-z, and for each one, print the letter, and then place some code that i already have working to display all items in my database that begin with that letter. Currently, i'm using a select to retrieve the first letter of all the item names which i display. However, the requirement is to display all letters, and then show 'no items to display' where there are no items. So, i can no longer use my select, which only returns the letters that have items.
How can I do this, without hardcoding each letter, and then calling my template 26 times after each one?
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="kItemBy1stLetter" match="item"
use="substring(.,1,1)"/>
<xsl:variable name="vDoc" select="/"/>
<xsl:variable name="vAlphabet" select=
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
/>
<my:message>No items found.</my:message>
<xsl:variable name="vMessage" select="document('')/*/my:message"/>
<xsl:template match="/">
<xsl:for-each select=
"(document('')//node()|document('')//#*|document('')//namespace::*)
[ not(position() > 26)]
">
<xsl:variable name="vcurLetter" select=
"substring($vAlphabet, position(), 1)"/>
<xsl:for-each select="$vDoc">
<xsl:variable name="vSearchResult" select=
"key('kItemBy1stLetter', $vcurLetter)"/>
<xsl:value-of select="concat('
',$vcurLetter, ':
')"/>
<xsl:copy-of select="$vSearchResult | $vMessage[not($vSearchResult)]/text()"/>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document (playing the role of "database"):
<database>
<item>Bicycles</item>
<item>Computers</item>
<item>Cars</item>
<item>Forks</item>
<item>Gellato</item>
<item>Hypervehicles</item>
<item>Ichtiosaurs</item>
<item>Jobs</item>
<item>Knots</item>
<item>Lens</item>
<item>Miracles</item>
<item>Notes</item>
</database>
produces the wanted result:
A:
No items found.
B:
<item>Bicycles</item>
C:
<item>Computers</item>
<item>Cars</item>
D:
No items found.
E:
No items found.
F:
<item>Forks</item>
G:
<item>Gellato</item>
H:
<item>Hypervehicles</item>
I:
<item>Ichtiosaurs</item>
J:
<item>Jobs</item>
K:
<item>Knots</item>
L:
<item>Lens</item>
M:
<item>Miracles</item>
N:
<item>Notes</item>
O:
No items found.
P:
No items found.
Q:
No items found.
R:
No items found.
S:
No items found.
T:
No items found.
U:
No items found.
V:
No items found.
W:
No items found.
X:
No items found.
Y:
No items found.
Z:
No items found.

Resources