[xquery-talk] Stop Conversion of Character Entities

Michael Kay mike at saxonica.com
Tue Feb 21 14:35:44 PST 2012


There's no equivalent in XQuery to XSLT's d-o-e. Which is probably a 
good thing; d-o-e has caused no end of problems over the years; it 
breaks the architectural boundary between the transformer and serializer 
in a way that inevitably leads to grief. There are cases where it's 
needed - usually cases like this one, where it appears a receiving 
application is making distinctions between two lexical representations 
of the same data model that no self-respecting XML application should make.

I think the correct workaround for this kind of problem is to output 
something like a processing-instruction <?x10?> and then do 
post-processing of the serialized output (or customization of the 
serializer pipeline) to turn this into what the application requires.

Michael Kay
Saxonica


On 21/02/2012 21:01, Betty Harvey wrote:
> Yes Excel XML 2003 and 2007 understands character entities because it
> understands XML
>
> Converting to CSV wouldn't solve the problem of getting a list in a single
> cell.
>
> Also, I am doing some fancy formatting in the Excel:
>
> 1.  Header Rows with different fonts and colors
> 2.  Freeze panes
> 3.  Filtering on columns turned on.
> 4.  Different fonts (colors, bold, italics)
> 4.  Multiple worksheets
>
> Excel is a little persnickety and I have solved all of the above.  In XSLT
> I have also solved above, as well as having lists in a single cell because
> of the<xsl:text disable-output-escaping="yes">  command.   In XSLT I
> would:
>
> <xsl:text disable-output-escaping="yes">&</xsl:text>#10;
>
> I could always let it wrapped but it looks messy and isn't pleasing to the
> eyes of the users using the reports I am generating.
>
> I can't find an equivalent in XQuery.
>
> Thanks!
>
> Betty
>
>> OK Back to the beginning
>>
>> First off I didnt know Excel understood XML character entities ...but
>> trusting you
>> what does this give you
>>
>>
>> <cell><data>hello&#10;big&#10;world</data></cell>
>>
>> Alternatively have you thought of converting to CSV instead and let Excel
>> read that ?
>>
>> ----------------------------------------
>> David A. Lee
>> dlee at calldei.com
>> http://www.xmlsh.org
>>
>>
>>> -----Original Message-----
>>> From: Betty Harvey [mailto:harvey at eccnet.com]
>>> Sent: Tuesday, February 21, 2012 3:44 PM
>>> To: David Lee
>>> Cc: Andrew Welch; xquery-discuss; Mike Sokolov
>>> Subject: Re: [xquery-talk] Stop Conversion of Character Entities
>>>
>>> This is what I getting (simplified) in the output -- the linefeeds are
>>> being created:
>>>
>>> <cell><data>hello
>>> big
>>> world</data></cell>
>>>
>>>
>>> What I want is:
>>>
>>> <cell><data>hello
big
world</data></cell>
>>>
>>> When the Excel 2003 file is opened in Excel the cell is coming out:
>>>
>>> hello big world
>>>
>>> What I want it displayed in list form:
>>>
>>> hello
>>> big
>>> world
>>>
>>> Excel doesn't recognize actual linefeeds as linefeeds in a cell -- it
>>> requires the actual character entity
>>>
>>> Betty
>>>
>>>
>>>> I guess Im confused as to what your problem is.
>>>> Here is ML code I just ran
>>>>
>>>> <p>hello world
</p>
>>>>
>>>>
>>>> Result:
>>>>
>>>> <p>hello world
>>>> </p>
>>>>
>>>>
>>>> So my next question is ... how are you printing the result of a
>>> MarkLogic
>>>> XQuery output ?  It seems likely the problem is in your serialization
>>> code
>>>> not ML itself
>>>>
>>>>
>>>>
>>>> ----------------------------------------
>>>> David A. Lee
>>>> dlee at calldei.com
>>>> http://www.xmlsh.org
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On
>>>>> Behalf Of Betty Harvey
>>>>> Sent: Tuesday, February 21, 2012 3:24 PM
>>>>> To: Andrew Welch
>>>>> Cc: xquery-discuss; Mike Sokolov
>>>>> Subject: Re: [xquery-talk] Stop Conversion of Character Entities
>>>>>
>>>>> I guess I should have said MarkLogic is the XQuery engine.  I thought
>>>>> there might be generic solution.
>>>>>
>>>>> Betty
>>>>>
>>>>>>> I have tried just about every trick I can think of with no
>>> success.
>>>>>>
>>>>>> declare namespace saxon="http://saxon.sf.net/";
>>>>>> declare option saxon:output "method=text";
>>>>>>
>>>>>> 'a&#10; b'
>>>>>>
>>>>>> returns
>>>>>>
>>>>>> a
 b
>>>>>>
>>>>>> --
>>>>>> Andrew Welch
>>>>>> http://andrewjwelch.com
>>>>>>
>>>>>
>>>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
>>>>> Betty Harvey                         | Phone:  410-787-9200  FAX:
>>> 9830
>>>>> Electronic Commerce Connection, Inc. |
>>>>> harvey at eccnet.com                    | Washington,DC XML Users Grp
>>>>> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
>>>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
>>>>> Member of XML Guild (www.xmlguild.org)
>>>>> _______________________________________________
>>>>> talk at x-query.com
>>>>> http://x-query.com/mailman/listinfo/talk
>>>>
>>>>
>>>> _______________________________________________
>>>> talk at x-query.com
>>>> http://x-query.com/mailman/listinfo/talk
>>>>
>>>
>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
>>> Betty Harvey                         | Phone:  410-787-9200  FAX: 9830
>>> Electronic Commerce Connection, Inc. |
>>> harvey at eccnet.com                    | Washington,DC XML Users Grp
>>> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
>>> Member of XML Guild (www.xmlguild.org)
>>
>>
>
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> Betty Harvey                         | Phone:  410-787-9200  FAX: 9830
> Electronic Commerce Connection, Inc. |
> harvey at eccnet.com                    | Washington,DC XML Users Grp
> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
> Member of XML Guild (www.xmlguild.org)
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>



More information about the talk mailing list