What is the difference between // and .// in XPath?

In XPath, // and .// are both syntactic abbreviations: // is short for /descendant-or-self::node()/ .// is short for self::node()/descendant-or-self::node()/ The descendant-or-self axis contains the context node and all descendents of the context node. So the difference between // and .// reduces to a difference in context nodes. For //, the context node is the root … Read more

How to import XML with nested nodes (parent/child relationships) into Access?

What you need to do is transform your XML data into a format that works better with Access. Specifically, you need to insert the parent key value (assuming that it is C_NOT in this case) into each child node. The following XSLT file will do that for you <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output indent=”yes”/> <xsl:strip-space elements=”*”/> … Read more

Finding the difference between two dateTimes in XSLT

I am getting the error: … xsl:version: only 1.0 features are supported Here’s a purely XSLT 1.0 solution: <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes”/> <xsl:strip-space elements=”*”/> <xsl:template match=”event”> <xsl:variable name=”start”> <xsl:call-template name=”dateTime-to-seconds”> <xsl:with-param name=”dateTime” select=”start/@time” /> </xsl:call-template> </xsl:variable> <xsl:variable name=”end”> <xsl:call-template name=”dateTime-to-seconds”> <xsl:with-param name=”dateTime” select=”end/@time” /> </xsl:call-template> </xsl:variable> <xsl:variable name=”duration” select=”$end – $start” … Read more

How to mimic copy-namespaces=”no” in XSLT 1.0?

The following mimics the XSLT 2.0 construct: Create templates in a mode that will re-construct your nodes without namespaces: <!– generate a new element in the same namespace as the matched element, copying its attributes, but without copying its unused namespace nodes, then continue processing content in the “copy-no-namepaces” mode –> <xsl:template match=”*” mode=”copy-no-namespaces”> <xsl:element … Read more

how to edit XML using bash script?

To change tag‘s value to 2 and tag1‘s value to 3, using XMLStarlet: xmlstarlet ed \ -u ‘/root/tag’ -v 2 \ -u ‘/root/tag1’ -v 3 \ <old.xml >new.xml Using your sample input: xmlstarlet ed \ -u ‘/root/tag’ -v 2 \ -u ‘/root/tag1’ -v 3 \ <<<‘<root><tag>1</tag><tag1>2</tag1></root>’ …emits as output: <?xml version=”1.0″?> <root> <tag>2</tag> <tag1>3</tag1> </root>