I have the following XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<html>
<body>
<xsl:for-each select="AdvReqIMailMsg">
<a><xsl:attribute name="href">
http://<xsl:value-of select="BackSideUrl"/>/customerlogin.asp?P=<xsl:value-of select="DynaCalPath"/></xsl:attribute >
Login to View History of This Request
</a>
<br/>
</xsl:for-each>
</body>
</html>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The result has the following:
<a href="
 http://dotnet.dynacal.com/customerlogin.asp?P=DEMO8">
Login to View History of This Request
</a>
Why are the 

and all the spaces there? I am new to XSLT and my google searches haven't turned anything up that I understood.
Thanks,
Shawn
XSLT is used to transform XML documents into XHTML documents, or into other XML documents.
XSLT has become the language of choice for a very wide range of XML applications. It is of course still used to produce XSL-FO documents for printing, but it is also used to integrate back-end software for Web sites.
XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.
One advantage that XSLT provides over CSS is that while CSS can “decorate the tree,” XSLT can rearrange it, fetching nodes from one place in the input tree and writing them somewhere else in the output tree.
The &#A;
is an encoded newline character.
It and the spaces are preserved from the newline and spaces in your XSLT.
Just use:
<a href="http://{BackSideUrl}/customerlogin.asp?P={DynaCalPath}">
Login to View History of This Request
</a>
This (use of AVT -- Attribute-Value-Templates) is both shorter and more readable.
The reason for the reported behavior, as explained in almost all answers, is that the value of the attribute href
is constructed (partly) from text-node that contains the NL character.
Such issues are result from a purely human, psychological phenomenon: we clearly see the NL whenever it is surrounded by non-white-space, however we are NL-blind whenever the NL is at the start or at the end of a block of text. It would be a useful feature of any XSLT/XML IDE to show on request groups of special "invisible" characters, such as NL and CR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With