SSIS - How to parse multilevel xml into a different SQL Server table? - sql-server

Can you please help me with this? I have thousands of xml files like this:
<eolresult>
<eolpresetting>
<datetime>04.06.2021 15:26:20</datetime>
<order id="3I6LAKPVSLXSK316_FLX101xxxxxxxxxxxxxx000SK35X3PN9P40006C24A4NORL0L7P1XVV0008I96T24D3ZZF0006A0LTS0000"/>
</eolpresetting>
<testresult>IO</testresult>
<results>
<!-- PRN="3I6LAKPVSLXSK316_FLX101xxxxxxxxxxxxxx000SK35X3PN9P40006C24A4NORL0L7P1XVV0008I96T24D3ZZF0006A0LTS0000" -->
<test name="Airbag SAB">
<value name="Measured value - Generator">2,151977</value>
<value name="Low limit - Generator">1,74</value>
<value name="High limit - Generator">2,46</value>
<value name="Measured value - Break contact 1">5,079372</value>
<value name="Minumum value - Break contact 1">1,73</value>
<value name="Measured value - Break contact 2">5,104009</value>
<value name="Minumum value - Break contact 2">1,73</value>
<value name="Test OK">True</value>
</test>
<test name="Airbag CAB">
<value name="Measured value - Generator">2,131677</value>
<value name="Low limit - Generator">1,74</value>
<value name="High limit - Generator">2,26</value>
<value name="Measured value - Break contact 1">5,061298</value>
<value name="Minumum value - Break contact 1">1,73</value>
<value name="Measured value - Break contact 2">5,094279</value>
<value name="Minumum value - Break contact 2">1,73</value>
<value name="Test OK">True</value>
</test>
<test name="Heating">
<value name="Measured value">1,34909</value>
<value name="Low limit">1,22</value>
<value name="High limit">1,72</value>
<value name="Test OK">True</value>
</test>
<test name="SBR">
<value name="Measured value - Low force">399,8799</value>
<value name="Low limit - Low force">332</value>
<value name="High limit - Low force">468</value>
<value name="Measured value - Low force - Force [kg]">5,176686</value>
<value name="Low limit - Low force - Force [kg]">5,1</value>
<value name="High limit - Low force - Force [kg]">6,4</value>
<value name="Regulator Active - Low force">True</value>
<value name="Measured value - High force">100,0365</value>
<value name="Low limit - High force">83</value>
<value name="High limit - High force">117</value>
<value name="Measured value - High force - Force [kg]">33,72532</value>
<value name="Low limit - High force - Force [kg]">33,6</value>
<value name="High limit - High force - Force [kg]">34,3</value>
<value name="Regulator Active - High force">True</value>
<value name="Strain Gauge - Tare [kg]">-10,68025</value>
<value name="Test OK">True</value>
</test>
<test name="Headrests">
<value name="Force - Measured">16,61965</value>
<value name="Force - Low Limit">15,81</value>
<value name="Force - High Limit">17,64</value>
<value name="Regulator Active">True</value>
<value name="Strain Gauge - Tare [kg]">-8,725739E-02</value>
<value name="Test OK">True</value>
</results>
</eolresult>
And I would like to import this data into a SQL Server database into separate tables, defined by the "test name" which every tables should contain order id.
I tried to follow some guides on the internet but without success.
Thank you so much

Related

Need to remove some properties from Junit xml report generated through SOAPUI (open source)

While running my API test via jenkins(linux machine), its generating Junit report xml with some invalid character in properties tags.
<property name="LESS_TERMCAP_us" value="[04;38;5;111m"/>
Due to which jenkins throws error for invalid xml.
How can I remove properties from the generated xml.
Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Sanity" tests="3" failures="3" errors="0" time="5.354">
<properties><property name="JOB_NAME" value="QA-API-Automation-Sanity"/>
<property name="java.vendor" value="Oracle Corporation"/><property name="PWD" value="/var/lib/jenkins"/><property name="sun.java.launcher" value="SUN_STANDARD"/><property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/><property name="PATH" value="/var/lib/jenkins/tools/chromedriver:/usr/local/bin:/bin:/usr/bin:/opt/aws/bin:/usr/lib/apache-maven-3.3.9/bin/"/><property name="JENKINS_HOME" value="/var/lib/jenkins"/><property name="AWS_SDK_LOAD_CONFIG" value="true"/><property name="HUDSON_SERVER_COOKIE" value="2567307d622fab24"/><property name="POM_ARTIFACTID" value="apitest"/><property name="os.name" value="Linux"/><property name="EXECUTOR_NUMBER" value="3"/><property name="sun.boot.class.path" value="/usr/java/jdk1.8.0_60/jre/lib/resources.jar:/usr/java/jdk1.8.0_60/jre/lib/rt.jar:/usr/java/jdk1.8.0_60/jre/lib/sunrsasign.jar:/usr/java/jdk1.8.0_60/jre/lib/jsse.jar:/usr/java/jdk1.8.0_60/jre/lib/jce.jar:/usr/java/jdk1.8.0_60/jre/lib/charsets.jar:/usr/java/jdk1.8.0_60/jre/lib/jfr.jar:/usr/java/jdk1.8.0_60/jre/classes"/><property name="POM_DISPLAYNAME" value="APITest"/><property name="java.vm.specification.vendor" value="Oracle Corporation"/><property name="ROOT_BUILD_CAUSE" value="MANUALTRIGGER"/><property name="NODE_LABELS" value="QA-Slave qa-slave"/><property name="java.runtime.version" value="1.8.0_60-b27"/><property name="user.name" value="jenkins"/><property name="SSH_CONNECTION" value="52.14.5.155 42186 10.0.0.142 22"/><property name="guice.disable.misplaced.annotation.check" value="true"/><property name="SSH_CLIENT" value="52.14.5.155 42186 22"/><property name="PYTHON_INSTALL_LAYOUT" value="amzn"/><property name="user.language" value="en"/><property name="RUN_CHANGES_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/display/redirect?page=changes"/><property name="JOB_BASE_NAME" value="QA-API-Automation-Sanity"/><property name="BUILD_DISPLAY_NAME" value="#22"/><property name="sun.boot.library.path" value="/usr/java/jdk1.8.0_60/jre/lib/amd64"/><property name="AWS_AUTO_SCALING_HOME" value="/opt/aws/apitools/as"/><property name="java.version" value="1.8.0_60"/><property name="user.timezone" value="Etc/UTC"/><property name="sun.arch.data.model" value="64"/><property name="NODE_NAME" value="QA-Slave"/><property name="NLSPATH" value="/usr/dt/lib/nls/msg/%L/%N.cat"/><property name="java.endorsed.dirs" value="/usr/java/jdk1.8.0_60/jre/lib/endorsed"/><property name="BUILD_ID" value="22"/><property name="sun.cpu.isalist" value=""/><property name="sun.jnu.encoding" value="UTF-8"/><property name="file.encoding.pkg" value="sun.io"/><property name="SHELL" value="/bin/bash"/><property name="file.separator" value="/"/><property name="java.specification.name" value="Java Platform API Specification"/>
<property name="LESS_TERMCAP_us" value="[04;38;5;111m"/>
<property name="java.class.version" value="52.0"/><property name="org.slf4j.simpleLogger.defaultLogLevel" value="info"/><property name="user.country" value="US"/><property name="securerandom.source" value="file:/dev/./urandom"/><property name="java.home" value="/usr/java/jdk1.8.0_60/jre"/><property name="java.vm.info" value="mixed mode"/><property name="LESSOPEN" value="||/usr/bin/lesspipe.sh %s"/><property name="os.version" value="4.4.41-36.55.amzn1.x86_64"/><property name="EC2_AMITOOL_HOME" value="/opt/aws/amitools/ec2"/><property name="RUN_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/display/redirect"/>
<property name="LESS_TERMCAP_ue" value="[0m"/><property name="POM_VERSION" value="1.0-SNAPSHOT"/><property name="sun.font.fontmanager" value="sun.awt.X11FontManager"/><property name="path.separator" value=":"/><property name="java.vm.version" value="25.60-b23"/><property name="GIT_PREVIOUS_COMMIT" value="c20674b0f57ce7beb1a881f19bdfeae2a5b602e7"/><property name="JOB_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/display/redirect"/><property name="SHLVL" value="1"/><property name="_" value="/usr/bin/java"/><property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/><property name="JAVA_HOME" value="/usr/java/jdk1.8.0_60"/><property name="sun.io.unicode.encoding" value="UnicodeLittle"/><property name="awt.toolkit" value="sun.awt.X11.XToolkit"/><property name="LOGNAME" value="jenkins"/><property name="POM_PACKAGING" value="jar"/><property name="HOME" value="/home/jenkins"/><property name="POM_GROUPID" value="com.api"/><property name="user.home" value="/home/jenkins"/><property name="JENKINS_SERVER_COOKIE" value="2567307d622fab24"/><property name="BUILD_TAG" value="jenkins-QA-API-Automation-Sanity-22"/><property name="HUDSON_URL" value="https://jenkins.gl-poc.com/"/><property name="java.specification.vendor" value="Oracle Corporation"/><property name="CLASSPATH" value=""/><property name="java.library.path" value="/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib"/><property name="java.vendor.url" value="http://java.oracle.com/"/><property name="ROOT_BUILD_CAUSE_MANUALTRIGGER" value="true"/><property name="java.vm.vendor" value="Oracle Corporation"/><property name="maven.home" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/><property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/><property name="sun.java.command" value="jenkins.maven3.agent.Maven33Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9 /var/lib/jenkins/slave.jar /var/lib/jenkins/maven33-interceptor.jar /var/lib/jenkins/maven3-interceptor-commons.jar 44390"/><property name="java.class.path" value="/var/lib/jenkins/maven33-agent.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/boot/plexus-classworlds-2.5.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/conf/logging"/><property name="EC2_HOME" value="/opt/aws/apitools/ec2"/><property name="java.vm.specification.name" value="Java Virtual Machine Specification"/><property name="java.vm.specification.version" value="1.8"/><property name="MAIL" value="/var/mail/jenkins"/><property name="M2_HOME" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/>
<property name="LESS_TERMCAP_me" value="[0m"/><property name="sun.cpu.endian" value="little"/><property name="sun.os.patch.level" value="unknown"/>
<property name="LESS_TERMCAP_md" value="[01;38;5;208m"/>
<property name="LESS_TERMCAP_mb" value="[01;31m"/>
<property name="java.io.tmpdir" value="/tmp"/><property name="PATH+MAVEN" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/bin"/><property name="HUDSON_HOME" value="/var/lib/jenkins"/>
<property name="LESS_TERMCAP_se" value="[0m"/><property name="OLDPWD" value="/home/jenkins"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="BUILD_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/"/>
<property name="os.arch" value="amd64"/><property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/><property name="java.ext.dirs" value="/usr/java/jdk1.8.0_60/jre/lib/ext:/usr/java/packages/lib/ext"/><property name="JOB_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/"/><property name="_JAVA_OPTIONS" value="-Xmx2048m"/><property name="user.dir" value="/var/lib/jenkins/workspace/QA-API-Automation-Sanity"/><property name="MAVEN_HOME" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/><property name="line.separator" value="
"/>
<property name="BUILD_NUMBER" value="22"/><property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/><property name="JENKINS_URL" value="https://jenkins.gl-poc.com/"/>
<property name="GIT_BRANCH" value="origin/develop"/><property name="PATH+CHROMEDRIVER" value="/var/lib/jenkins/tools/chromedriver"/><property name="BUILD_CAUSE_MANUALTRIGGER" value="true"/><property name="GIT_COMMIT" value="ad5e9221a4f489a8a60e60bed86061be514bccda"/><property name="LANG" value="en_US.UTF-8"/><property name="file.encoding" value="UTF-8"/><property name="maven3.interceptor" value="/var/lib/jenkins/maven33-interceptor.jar"/><property name="WORKSPACE" value="/var/lib/jenkins/workspace/QA-API-Automation-Sanity"/><property name="maven3.interceptor.common" value="/var/lib/jenkins/maven3-interceptor-commons.jar"/><property name="AWS_PATH" value="/opt/aws"/><property name="AWS_ELB_HOME" value="/opt/aws/apitools/elb"/><property name="AWS_CLOUDWATCH_HOME" value="/opt/aws/apitools/mon"/><property name="java.specification.version" value="1.8"/><property name="BUILD_CAUSE" value="MANUALTRIGGER"/><property name="USER" value="jenkins"/><property name="XFILESEARCHPATH" value="/usr/dt/app-defaults/%L/Dt"/><property name="GIT_URL" value="ssh://git#bitbucket.pearson.com/glpnfr/glp-api-automation-qa.git"/></properties>
<testcase name="Login" time="1.595">
<failure type="Failing due to failed test step" message="Failing due to failed test step">
<![CDATA[<h3><b>claimTokenIdTransfer Failed</b></h3><pre>Error performing transfer [claimTokenRetrieval] - Missing target property
</pre><hr/><h3><b>retrievalClaim Failed</b></h3><pre>[Valid HTTP Status Codes] Response status code:401 is not in acceptable list of status codes
</pre><hr/>]]>
</failure>
</testcase>
</testsuite>
Here you go, comments in-line:
Pass the xml as string to parseText method.
//Pass xml string
def pxml = new XmlSlurper().parseText(xml)
//Get the suites
def suites = pxml.'**'.findAll{ it.name() == 'testsuite' }
//Remove properties node
suites.each{ it.properties.replaceNode {} }
//This gives the new xml without properties element
def output = groovy.xml.XmlUtil.serialize(pxml)​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
//Below would unescape the xml
def map = ['<' : '<', '>' : '>', '"' : '"', '&apos;':'\'', '&':'&']
map.collect {k,v -> output = output.replaceAll(k,v)}
println output​
You can quickly try this online Demo

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>

How to select rows in cassandra for indexing in solr

I have rows in cassasndra, how would I go on about quering those rows in order to index them for example in solr. What query or what way should i use in order to query all those rows in cassandra once?
Please find below the example to integrate Cassandra and Solr:
CREATE TABLE tutor (
id int,
name text,
org text,
dep text,
sal text,
place text,
PRIMARY KEY ((org),name)
)
cqlsh:test> select * FROM tutor;
org | name | dep | id | place | sal
------+------+------+----+---------+------
org1 | abc | dep1 | 1 | sanjose | 4500
org1 | bbb | dep1 | 2 | sanjose | 5500
org2 | ccc | dep1 | 3 | sanjose | 5500
org2 | ddd | dep2 | 4 | sanjose | 5500
org2 | eee | dep3 | 5 | sanjose | 4500
org2 | fff | dep4 | 6 | sanjose | 7500
Requirements for SOLR and Cassandra integration:
SOLR version:
solr 4.9.0
Lib/Jar:
Cassandra :
cassandra-all-1.2.5.jar
libthrift-0.6.0.jar
cassandra-thrift-1.2.5.jar
Daata Import Handler:
solr-dataimporthandler-4.9.0.jar
solr-dataimporthandler-extras-4.9.0.jar
MySql:
mysql-connector-java-5.1.31-bin.jar
In Solor: Following files to be update:
• dataconfig.xml
• schema.xml
• solorconfig.xml
• dataconfig.xml
Here we have to update the JDBC connector for CASSANDRA.
< dataConfig>
< dataSource type="JdbcDataSource"
driver="org.apache.cassandra.cql.jdbc.CassandraDriver"
url="jdbc:cassandra://10.234.31.231:9160/test"
autoCommit="true"/>
< document name="content">
< entity name="test"
query="SELECT id,org,name,dep,place,sal from tutor" autoCommit="true">
< field column="id" name="id" />
< field column="org" name="org" />
< field column="name" name="name" />
< field column="dep" name="dep" />
< field column="place" name="place" />
< field column="sal" name="sal" />
< entity>
< document>
< dataConfig>
schema.xml
< field name="id" type="string" indexed="true" stored="true" required="true" />
< field name="org" type="string" indexed="true" stored="true" required="true" />
< field name="dep" type="string" indexed="true" stored="true" required="true" />
< field name="place" type="string" indexed="true" stored="true" required="true" />
< field name="sal" type="string" indexed="true" stored="true" required="true" />
Solorconfig.xml
< ! - - Add your library Path - →
< lib dir="/home/solr/lib" regex="solr-dataimporthandler-.*.jar" />
< lib dir="/home/solr/lib" regex="cassandra-jdbc-.*.jar" />
< lib dir="/home/solr/lib" regex="cassandra-all-.*.jar" />
< lib dir="/home/solr/lib" regex="cassandra-thrift-.*.jar" />
< lib dir="/home/solr/lib" regex="libthrift-.*.jar" />
. . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
< requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
< lst name="defaults">
< str name="config">dataconfigCassandra.xml
< /lst>
Not sure how is your setup (which language you are using), but probably the best is to use a Cassandra client library and write an applications to query all the entries (rows) of your cassandra "column family" (tables) and then write the data you want to index from each row in Solr. Here you have a nice overview of several clients for cassandra: http://www.datastax.com/download/clientdrivers.
To perform the "read all entries" you can perform the following "native query":
select * from columnfamilyname;
This will depend very much on the client library you use... but I imagine most of the clients allow you to do such "native queries" (like the ones you perform in Cassandra cassandra-cli or cqlsh).
Be careful how big is your DB to perform this query... In that case if you if they are indexed/ordered (by key) you can perform a query such as: select * from columnfamily where indexkey > 101 limit 100 allow filtering.
After you create the "initial index" in Solr, most probably you should also use an update method that keeps solr index updated with new entries of the Cassandra DB.

Fuse ESB - Camel issue

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" />

Delete XML nodes in SQL server based on conditions

I have xml that looks like
<MeasureSet>
<MeasureSetType val_type="name">Variant</MeasureSetType>
<Measure>
<MeasureType val_type="name">single nucleotide variant</MeasureType>
<AttributeSet>
<MeasureAttributeType val_type="name">HGVS</MeasureAttributeType>
<Attribute>NM_000054.4:c.838dupT</Attribute>
</AttributeSet>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">10820168</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed" />
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">9773787</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">18726898</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed" />
</Citation>
</Measure>
</MeasureSet>
I want to delete the Citation element nodes that have Citation/ID/#Source = "PubMed" and Citation/ID is empty
This deletes only the ID element, but the correct ones
SET #myBlob.modify('delete //Citation/ID[#Source = ''PubMed''
and string-length(string(number(.))) = 0]')
and this deletes all Citation elements
SET #myBlob.modify('delete //Citation[ID/#Source = ''PubMed''
and string-length(string(number(.))) = 0]')
Seems there should be an easy solution I'm not hitting on. Any suggestions? Thanks
Your second one is checking the length of the wrong element - it's looking at (.), which is here the Citation element (because it's in a predicate on the Citation element). Use instead
SET #myBlob.modify('
delete //Citation[ID/#Source = ''PubMed''
and string-length(string(number(ID[1]))) = 0]')
where I have changed . to ID[1]. The [1] is needed because "'number()' requires a singleton (or empty sequence)".

Resources