How to create a boolean value?

The value of the $var variable as defined in:    <xsl:variable name=”var” select=”boolean(‘false’)”/> is    true() This is because in XPath “false” is an ordinary string, as opposed to false(), which is the constructor for the boolean value false() The two boolean values in XPath are (note that they are constructed!):    true() and false() The detail of … Read more

XPath and XSLT 2.0 for .NET? [closed]

I don’t think they’ll add support for XPath 2.0 or XSLT 2.0 any time soon. However, you shouldn’t feel bad if these are not part of the BCL, as long as you have 3rd party implementations available: Saxon: XPath 3.1, XQuery 3.1, XSLT 3.0 XmlPrime: XPath 3.1, XQuery 3.1, XSLT 2.0 QueryMachine: XPath 2.0, XQuery … Read more

XSLT string replace

replace isn’t available for XSLT 1.0. Codesling has a template for string-replace you can use as a substitute for the function: <xsl:template name=”string-replace-all”> <xsl:param name=”text” /> <xsl:param name=”replace” /> <xsl:param name=”by” /> <xsl:choose> <xsl:when test=”$text=”” or $replace=””or not($replace)” > <!– Prevent this routine from hanging –> <xsl:value-of select=”$text” /> </xsl:when> <xsl:when test=”contains($text, $replace)”> <xsl:value-of select=”substring-before($text,$replace)” … Read more

How can I make XSLT work in chrome?

The other answer below by Eric is wrong. The namespace declaration he mentioned had nothing to do with the problem. The real reason it doesn’t work is due to security concerns (cf. issue 4197, issue 111905). Imagine this scenario: You receive an email message from an attacker containing a web page as an attachment, which … Read more

Can an XSLT insert the current date?

XSLT 2 Date functions are available natively, such as: <xsl:value-of select=”current-dateTime()”/> There is also current-date() and current-time(). XSLT 1 Use the EXSLT date and times extension package. Download the date and times package from GitHub. Extract date.xsl to the location of your XSL files. Set the stylesheet header. Import date.xsl. For example: <xsl:stylesheet version=”1.0″ xmlns:date=”http://exslt.org/dates-and-times” … Read more

How to concat a string to xsl:value-of select=”…?

You can use the rather sensibly named xpath function called concat here <a> <xsl:attribute name=”href”> <xsl:value-of select=”concat(‘myText:’, /*/properties/property[@name=”report”]/@value)” /> </xsl:attribute> </a> Of course, it doesn’t have to be text here, it can be another xpath expression to select an element or attribute. And you can have any number of arguments in the concat expression. Do … Read more

Is XSLT worth it? [closed]

So much negativity! I’ve been using XSLT for a good few years now, and genuinely love it. The key thing you have to realise is that it’s not a programming language it’s a templating language (and in this respect I find it indescribably superior to asp.net /spit). XML is the de facto data format of … Read more