atom feed9 messages in com.marklogic.developer.generalRe: [MarkLogic Dev General] Passing C...
FromSent OnAttachments
Jonathan Cook - FM&TFeb 21, 2012 2:56 am 
Geert JostenFeb 21, 2012 3:47 am 
Michael BlakeleyFeb 21, 2012 10:19 am 
Betty HarveyFeb 21, 2012 4:14 pm 
David LeeFeb 21, 2012 4:45 pm 
Michael BlakeleyFeb 21, 2012 4:58 pm 
Betty HarveyFeb 21, 2012 5:43 pm 
David LeeFeb 21, 2012 6:18 pm 
Geert JostenFeb 25, 2012 11:54 am 
Subject:Re: [MarkLogic Dev General] Passing Character Entities to Output
From:Geert Josten (
Date:Feb 25, 2012 11:54:13 am

Hi Betty,

Your thread caught my attention earlier, but failed to look into in before. There are a few ways out I guess, but they might not be very elegant..

One option is to xdmp:quote the XML, and do a blunt replace of '
' with '
'. Upon serialization by the App Server, all line ends will come out as '
'. But this replaces line ends before the root element as well.

A slightly more elegant way is to use xsl character maps. Something like this:

let $xsl := <xsl:stylesheet version="2.0" xmlns:xsl=""> <xsl:character-map name="escape-line-end"> <xsl:output-character character="&#10;" string="&amp;#10;"/> </xsl:character-map> <xsl:output use-character-maps="escape-line-end" /> <xsl:template match="/"> <xsl:copy-of select="/"/> </xsl:template> </xsl:stylesheet> return xdmp:xslt-eval($xsl, document { <test>&#10;<test>&#10;</test>&#10;</test> } )

Kind regards, Geert

-----Oorspronkelijk bericht----- Van: [mailto:general-] Namens Betty Harvey Verzonden: woensdag 22 februari 2012 3:10 Aan: MarkLogic Developer Discussion Onderwerp: Re: [MarkLogic Dev General] Passing Character Entities to Output

Thanks Mike:

I am afraid that won't work. The application is Microsoft Excel. I need linefeeds in a specific Cell to give a list values on individual lines in a single cell. Microsoft sees the binary line feed as just whitespace and treats it as whitespace and not a real linefeed. In order to get a linefeed into Excel in importing Excel 2003 XML the character entity &#10; is required.

I guess I am stuck with either (1) having the text wrap which is really messy looking; or (2) post processing the resulting XML file.

Technically there is no difference: &#10; *means* codepoint 10 to any XML processor. A tool that only works when reading one or the other is broken.

But you can configure your app server and set the "output sgml character entities" to "normal" - or anything other than "none". Then you should see this:

<cell> <data>hello&NewLine;big&NewLine;world</data> </cell>

I don't know if that's any better for your purposes, but at least it isn't the literal codepoint.

On 21 Feb 2012, at 16:41 , Betty Harvey wrote:

I asked this question on the XQuery list and it looks like this can't be done in straight XQuery. I am asking this question here just in case there is a MarkLogic function that can be used.

I need to pass a linefeed character to the output. I am creating Excel spreadsheets where I need a list on separate lines in a single cell. Excel recognizes the character entity &#10; for linefeeds.

My output needs to look like this:


The output I am getting is:

<cell><data>hello big world</data></cell>

I have tried several variations of:

let $newline := "&#10;" let $newline := fn:concat("&", "#10;")

etc. All having the same results, getting a linefeed instead of placing the actual character entity in the output.

Are there any MarkLogic tricks to passing a character entity through without serializing it?


/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Betty Harvey | Phone: 410-787-9200 FAX: 9830 Electronic Commerce Connection, Inc. | | Washington,DC XML Users Grp URL: | /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ Member of XML Guild (