[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
David Carlisle wrote:
Oops!
(side note:)
I tend to solve my own whitespace problems with character maps, so that I can use a private use character everywhere in my code. That way I do not need to think about the whitespace removal of the stylesheet:
inside a stylesheet dtd:
the xslt:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "../../xslt-common/dtd/webitor-transformation.dtd" >
<xsl:character-map name="substitutes">
<xsl:output-character character="&newline_substitute;" string="&newline;"/>
</xsl:character-map>
<xsl:output use-character-map="substitutes" />
In the example above there is no reason at all of course for using &nbsub; instead of unless for readability (but you could use &newline; too). However, when passing around variables, doing copy-of, value-of etc, or even a normalice-space, you can loose the newlines. This way you can preserve them more easily and, the better part, when I place an ⊄ anywhere, it will always be output (which is not so for )
There are other possibilities that have to do with linebreaking and proper indentation that are otherwise hard to achieve or may get lost in parameter passing as value-of instead of copy-of etc., but I am drifting too far away now from the OP's question....
(I wonder if this technique is used by others, too and for what purposes; I use similar tricks for easier handling of quote-escapes in source documents and outputting tab characters for indentation when normal indentation does not suffice)
-- Abel Braaksma
Re: [xsl] saxon xmlspy discrepancy in whitespace handling
Subject: Re: [xsl] saxon xmlspy discrepancy in whitespace handling From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Wed, 17 Jan 2007 14:45:24 +0100 |
David Carlisle wrote:
<xsl:variable name="newline" select=" ' ' " />
2nd one, not the 1st (which is equivalent to <xsl:variable
name="newline"/>
Oops!
(side note:)
I tend to solve my own whitespace problems with character maps, so that I can use a private use character everywhere in my code. That way I do not need to think about the whitespace removal of the stylesheet:
inside a stylesheet dtd:
<!ENTITY newline "&#x0A;" > <!ENTITY newline_substitute "" > <!-- mapped to newline --> <!ENTITY nsub "&newline_substitute;" > <!-- alias -->
the xslt:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "../../xslt-common/dtd/webitor-transformation.dtd" >
<xsl:stylesheet version = "2.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" >
<xsl:character-map name="substitutes">
<xsl:output-character character="&newline_substitute;" string="&newline;"/>
</xsl:character-map>
<xsl:output use-character-map="substitutes" />
<xsl:template match="/"> <xsl:value-of select=" '⊄' " /> </xsl:template> </xsl:stylesheet>
In the example above there is no reason at all of course for using &nbsub; instead of unless for readability (but you could use &newline; too). However, when passing around variables, doing copy-of, value-of etc, or even a normalice-space, you can loose the newlines. This way you can preserve them more easily and, the better part, when I place an ⊄ anywhere, it will always be output (which is not so for )
There are other possibilities that have to do with linebreaking and proper indentation that are otherwise hard to achieve or may get lost in parameter passing as value-of instead of copy-of etc., but I am drifting too far away now from the OP's question....
(I wonder if this technique is used by others, too and for what purposes; I use similar tricks for easier handling of quote-escapes in source documents and outputting tab characters for indentation when normal indentation does not suffice)
-- Abel Braaksma
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] saxon xmlspy discrepancy , David Carlisle | Thread | [xsl] saxon error, Alexey Nickolaenkov |
Re: [xsl] saxon xmlspy discrepancy , David Carlisle | Date | [xsl] saxon error, Alexey Nickolaenkov |
Month |