XSLT xsl:sequence. What is it good for..?

<xsl:sequence> on an atomic value (or sequence of atomic values) is the same as <xsl:copy-of> both just return a copy of their input. The difference comes when you consider nodes. If $n is a single element node, eg as defined by something like <xsl:variable name=”n” select=”/html”/> Then <xsl:copy-of select=”$n”/> Returns a copy of the node, … Read more

Convert String to Integer in XSLT 1.0

Adding to jelovirt’s answer, you can use number() to convert the value to a number, then round(), floor(), or ceiling() to get a whole integer. Example <xsl:variable name=”MyValAsText” select=”‘5.14′”/> <xsl:value-of select=”number($MyValAsText) * 2″/> <!– This outputs 10.28 –> <xsl:value-of select=”floor($MyValAsText)”/> <!– outputs 5 –> <xsl:value-of select=”ceiling($MyValAsText)”/> <!– outputs 6 –> <xsl:value-of select=”round($MyValAsText)”/> <!– outputs 5 … Read more

xsl: how to split strings?

I. Plain XSLT 1.0 solution: This transformation: <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output omit-xml-declaration=”yes” indent=”yes”/> <xsl:template match=”text()” name=”split”> <xsl:param name=”pText” select=”.”/> <xsl:if test=”string-length($pText)”> <xsl:if test=”not($pText=.)”> <br /> </xsl:if> <xsl:value-of select= “substring-before(concat($pText,’;’),’;’)”/> <xsl:call-template name=”split”> <xsl:with-param name=”pText” select= “substring-after($pText, ‘;’)”/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> when applied on this XML document: <t>123 Elm Street;PO Box 222;c/o James Jones</t> produces the … Read more

Does XSLT have a Split() function?

Use a recursive method: <xsl:template name=”output-tokens”> <xsl:param name=”list” /> <xsl:variable name=”newlist” select=”concat(normalize-space($list), ‘ ‘)” /> <xsl:variable name=”first” select=”substring-before($newlist, ‘ ‘)” /> <xsl:variable name=”remaining” select=”substring-after($newlist, ‘ ‘)” /> <id> <xsl:value-of select=”$first” /> </id> <xsl:if test=”$remaining”> <xsl:call-template name=”output-tokens”> <xsl:with-param name=”list” select=”$remaining” /> </xsl:call-template> </xsl:if> </xsl:template>

Generate/get Xpath from XML in Java

Update: @c0mrade has updated his question. Here is a solution to it: This XSLT transformation: <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”text”/> <xsl:strip-space elements=”*”/> <xsl:variable name=”vApos”>'</xsl:variable> <xsl:template match=”*[@* or not(*)] “> <xsl:if test=”not(*)”> <xsl:apply-templates select=”ancestor-or-self::*” mode=”path”/> <xsl:value-of select=”concat(‘=’,$vApos,.,$vApos)”/> <xsl:text>&#xA;</xsl:text> </xsl:if> <xsl:apply-templates select=”@*|*”/> </xsl:template> <xsl:template match=”*” mode=”path”> <xsl:value-of select=”concat(“https://stackoverflow.com/”,name())”/> <xsl:variable name=”vnumPrecSiblings” select= “count(preceding-sibling::*[name()=name(current())])”/> <xsl:if test=”$vnumPrecSiblings”> <xsl:value-of select=”concat(‘[‘, $vnumPrecSiblings … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)