XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
John WollnerSubject: Studio not recognizing CrLf
Author: John Wollner
Date: 22 Mar 2005 09:54 AM
I have a template to insert a <br> for each CR/LF sequence in the data.

I have yet to get this working, although it is a simple process in
theory. When I debug the "break" template, it appears that the processor
is unable to see the CR LF, although a search of the data in a text editor
finds the sequence w/ no problem.


DocumentRequirements2.xsl
Transform w/ CR LF Replacement

DocumentRequirementsRaw.txt
Data for the transform

Postnext
Tony LavinioSubject: Studio not recognizing CrLf
Author: Tony Lavinio
Date: 22 Mar 2005 10:42 AM
You can't solve it the way you want to.

According to http://www.w3.org/TR/REC-xml/#AVNormalize any literal
linefeed (&#xA;) or carriage-return (&#xD;) characters in attributes
are normalized to spaces before an XSLT engine ever sees them, by
a standards-compliant XML parser. So in XSLT you will never see the
linefeeds you are expecting. And for further reference, that same
XML parser will normalize &#xD;&#xA; to &#xA; so you only need to
test for the linefeed in your code. For details see
http://www.w3.org/TR/REC-xml/#sec-line-ends

You have a couple of options at least:
1. Change the emitting logic to send out entities
2. Use Convert-to-XML to parse the input and then send it to your XSLT

Postnext
John WollnerSubject: Studio not recognizing CrLf
Author: John Wollner
Date: 22 Mar 2005 10:59 AM
Pardon my ignorance - What do you mean by "Convert-to-XML"?

The data is already in XML from the source system.

Postnext
Tony LavinioSubject: Studio not recognizing CrLf
Author: Tony Lavinio
Date: 22 Mar 2005 11:51 AM
Even though it is in XML, you could parse it as raw text if you really
care about the line endings, and that's pretty much your only option if
you can't change the input XML (or at least get it out of the attributes.)
But no XSLT engine can see plain line endings in attributes.

See http://www.stylusstudio.com/docs/v62/d_flatfileconversion9.html for
some details on using it.

Postnext
Ivan PedruzziSubject: Studio not recognizing CrLf
Author: Ivan Pedruzzi
Date: 22 Mar 2005 02:56 PM
John,

Your input document is not very well designed.

XML attributes are suppose to hold a small text like a date or an ID.
Attribute value gets also normalized replacing EOL with space when the XML is parsed.

If you have control on your input the best would be having those long text hold by elements.

Prepocessing the raw text to replace EOL with <br/> is not an option
becaue you will end up having not well formed XML (tag inside attribute value)
Unless you replace EOL with some special string liek WIN_EOL then when processing
the XML replace WIN_EOL with <br/>

In XSLT 2 you can create pre-process step like the following

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="replace(unparsed-text('file:///c:/Temp/Stylus_Test_Cases/RequirementsRaw.xml', 'UTF-8'), '&#xD;&#xA;','WIN_EOL')"/>
</xsl:template>
</xsl:stylesheet>

Then input the result to your XSLT.
Just need change the "break" template

<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text,'WIN_EOL')">
<xsl:value-of select="substring-before($text,'WIN_EOL')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,'WIN_EOL')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Hope this helps
Ivan

Posttop
John WollnerSubject: Studio not recognizing CrLf
Author: John Wollner
Date: 22 Mar 2005 03:22 PM
After some effort, I got the provider to put the text into elements and now it works fine.

Thanks for the insite.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.