xsl-list
[Top] [All Lists]

RE: [xsl] .NET XSLT Parser and Indentation Whitespace Problem

2007-11-09 09:13:45
Hello,

Yes, I'm using literal text - I'm building an e-mail template system using
XSLT as an easy to use template engine.

I guess this issue is by design (at least for .NET's engine?). In that case
I might have to strip out the final output manually to clean up the
spaces...

--
Michael She 
Team Leader, Software Development
Multi-Vision Communications Inc.
P: (905) 470-8644 x254 (Follow-Me)
M: (416) 816-2566
E: mshe(_at_)mvcinc(_dot_)com
W: http://www.mvcinc.com


-----Original Message-----
From: Houghton,Andrew [mailto:houghtoa(_at_)oclc(_dot_)org] 
Sent: Friday, November 09, 2007 9:05 AM
To: mshe(_at_)mvcinc(_dot_)com
Subject: RE: [xsl] .NET XSLT Parser and Indentation Whitespace Problem


I believe the issue is that you placed the literal text in the template
stream.  The .NET XSLT parser is doing the correct thing.  Since you have
whitespace before the Hello in your template, it will be output in addition
to the string Hello.  Generally, to avoid this situation, you should use
xsl:value-of.  So change your template to:

  <xsl:template match="/">
    <xsl:value-of select="concat('Hello ',$Name)"/>
    <!-- ... -->
  </xsl:template>

and the indentation will not appear.


Andy.

-----Original Message-----
From: Michael She [mailto:mshe(_at_)mvcinc(_dot_)com] 
Sent: 09 November, 2007 02:44
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] .NET XSLT Parser and Indentation Whitespace Problem

Hello Everyone,

I've been Googling for a while and I can't seem to find an 
answer to this question. VS.NET 2005 adds automatic 
indentation to XSLT files... and this indentation is causing 
problems with formatting. I could manually fix the file, but 
this would only be a workaround which could break easily... 
so I'm wondering how you get XSLT to strip indentation. 

I have an XSLT file that looks like:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
  <xsl:param name="Name"/>
  <xsl:template match="/">
    Hello <xsl:value-of select="$Name"  />,

    We have received your e-mail, and your question is in the 
process of being routed to the appropriate department. Our 
customer service representatives will make every effort to 
respond to your message within 24 hours. In the meantime, if 
you have not already done so, please take a moment to look 
for your answer in the frequently asked questions (FAQ) 
section of our site.

    Thank you for taking the time to contact us. We value 
your opinions and appreciate your concerns. A customer 
service representative will be contacting you soon.

    Sincerely,

    MySite.com
  </xsl:template>
</xsl:stylesheet>

My output is looking like:

    Hello <xsl:value-of select="$Name"  />,

    We have received your e-mail, and your question is in the 
process of being routed to the appropriate department. Our 
customer service representatives will make every effort to 
respond to your message within 24 hours. In the meantime, if 
you have not already done so, please take a moment to look 
for your answer in the frequently asked questions (FAQ) 
section of our site.

    Thank you for taking the time to contact us. We value 
your opinions and appreciate your concerns. A customer 
service representative will be contacting you soon.

    Sincerely,

    MySite.com

Notice the indentation before each line?

How do I get the output to look like:

Hello <xsl:value-of select="$Name"  />,

We have received your e-mail, and your question is in the 
process of being routed to the appropriate department. Our 
customer service representatives will make every effort to 
respond to your message within 24 hours. In the meantime, if 
you have not already done so, please take a moment to look 
for your answer in the frequently asked questions (FAQ) 
section of our site.

Thank you for taking the time to contact us. We value your 
opinions and appreciate your concerns. A customer service 
representative will be contacting you soon.

Sincerely,

MySite.com

Basically I want .NET's XSLT engine to ignore the indentation 
in the XSLT file and treat each line as a flush new line?

Thanks!

--
Michael She
Team Leader, Software Development
Multi-Vision Communications Inc.
P: (905) 470-8644 x254 (Follow-Me)
M: (416) 816-2566
E: mshe(_at_)mvcinc(_dot_)com
W: http://www.mvcinc.com




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>