[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] regarding newline


Subject: [xsl] regarding newline
From: subbu@xxxxxxxxxxxx
Date: Thu, 11 Jul 2002 11:14:40 +0100

hi,
I have a problem with the new lines.
What i am doing is, I have formed a DTD file thaz called entityreference.dtd
( which i will make use in the xsl through doctype)
<!DOCTYPE xsl:stylesheet SYSTEM "D:\xsl-exp\characterEntities\entityref.dtd">
the following is the contents of this file

<!ENTITY space "&#160;"> <!-- space -->
<!ENTITY quots "&#34;"> <!-- double quotes-->
<!ENTITY newline  "&#xa;"> <!--new line--> etc.....
.
.
.
.

I did this so that  i may just refer to them in my XSL like
<xsl:value-of select = "@id"/> &space; <xsl:value-of select = "."/>
to get me a space between id and value
just to replace the code
<xsl:value-of select = "@id"/><xsl:text>&#160;</xsl:text><xsl:value-of select 
= "."/>

this works fine..

I now want to use the newline character.
so instead of using the <xsl:text>&#xa;</xsl:text>
i declare the entity in the dtd..

<!ENTITY newline  "&#xa;"> <!--new line-->

and try to do things like 
<xsl:value-of select = "@id"/> &newline;<xsl:value-of select = "."/>
nothin seems to happen..

I was going through the Michlael Kay's XSLT Reference and found that
"XML parser will normalize the attribute values.A tab or a newline is allways 
replaced by a single space unless it is written as a character reference such 
as <<&#9;>> or <<&#A>> "
I am not sure how to aceive what i want

I am how ever satisfied to use
<xsl:value-of select = "@id"/> <xsl:text>&#xa;</xsl:text><xsl:value-of select 
= "."/>
Which produces a newline between id and value..

Any ideas regarding what i should do ??
Wheather or not i am in the right track to declare entities in the dtd file and 
refer them in the XSL ..
The following is a snipp of the XSL code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "D:\characterEntities\entityref.dtd">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:template match="/">
 <xsl:for-each select="centers/center">
    <!-- space between id and value -->
    <xsl:value-of select="@id"/>&space;<xsl:value-of select ="."/>
    <!-- the above works same as coding <xsl:value-of 
select="@id"/><xsl:text>&#160;</xsl:text><xsl:value-of select ="."/>-->
 <!-- newline between id and value -->

<xsl:value-of select="@id"/>&newline;<xsl:value-of select ="."/>
<!-- the above does not produce any newline ,( newline defined in dtd as
<!ENTITY newline  "&#xa;"> <!--new line--> ) but instruction like
<xsl:value-of select="@id"/><xsl:text>&#xa;</xsl:text><xsl:value-of select 
="."/> gives me a newline character -->
</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

Any suggestions ??
Subbu

--------------------------------------------------------------
Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
http://www.boltblue.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords