Is there an XSL “contains” directive?

Sure there is! For instance: <xsl:if test=”not(contains($hhref, ‘1234’))”> <li> <a href=”https://stackoverflow.com/questions/569908/{$hhref}” title=”{$pdate}”> <xsl:value-of select=”title”/> </a> </li> </xsl:if> The syntax is: contains(stringToSearchWithin, stringToSearchFor)

In what order do templates in an XSLT document execute, and do they match on the source XML or the buffered output?

I love your question. You’re very articulate about what you do not yet understand. You just need something to tie things together. My recommendation is that you read “How XSLT Works”, a chapter I wrote to address exactly the questions you’re asking. I’d love to hear if it ties things together for you. Less formally, … 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

What are the differences between ‘call-template’ and ‘apply-templates’ in XSL?

<xsl:call-template> is a close equivalent to calling a function in a traditional programming language. You can define functions in XSLT, like this simple one that outputs a string. <xsl:template name=”dosomething”> <xsl:text>A function that does something</xsl:text> </xsl:template> This function can be called via <xsl:call-template name=”dosomething”>. <xsl:apply-templates> is a little different and in it is the real … Read more

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