Handling special characters
Tuesday, 3 March 2015 · 3 messages · last reply 4 Mar 2015
EA
Erol Akarsu3 Mar 2015 22:48 #
Hi,
I need to be able write some special characters into output xml file. I have HTTML3 characters like ρ (phase), Δ (delta) in XML. But they are printed into xml file as & expanded as "&"
They was being written as
ρ and Δ
But I want
ρ and Δ
How can I do it?
Thanks
Erol Akarsu
EA
Erol Akarsu4 Mar 2015 00:41 #
I think I need one thing.
How can I convert an HTML3 code to proper form?
Let's say I have the number 174 and like convert it to form ® (don't want ®)
how can I get it?
Quoted text · Erol Akarsu · 22 lines
On Tue, Mar 3, 2015 at 3:48 PM, Erol Akarsu <eakarsu at gmail.com> wrote: > Hi, > > I need to be able write some special characters into output xml file. I > have HTTML3 characters like ρ (phase), Δ (delta) in XML. But they > are printed into xml file as & expanded as "&" > > They was being written as > > &#961; and &#916; > > But I want > > ρ and Δ > > How can I do it? > > Thanks > > Erol Akarsu > >
GS
Graydon Saunders4 Mar 2015 00:53 #
Hi Erol --
When XML documents are parsed, any numeric character reference -- like ® -- can be parsed, giving U+00AE as a code point which will look like ® in the text, and which might, in this Unicode world, be the best option, or the parser can have a setting that will escape all the entity references, so you get the & turning into &. There isn't any way to avoid one or the other because of some intractable XML rules about entities.
Remember that so far as a parsed XML document is concerned, there's no difference between ® and ®; it's all the same U+00AE codepoint. Trying to maintain entities in a parsed XML document is never the simple way to do it.
I'd generally approach this by converting all the entities to code point representations of the actual characters on the input side, and worry about which, if any, entity representations I needed on the output side. Either the serializer or character mapping should be able to handle converting any codepoints you want to represent as HTML entities in the final output.
-- Graydon
Quoted text · Erol Akarsu · 31 lines
On Tue, Mar 3, 2015 at 5:41 PM, Erol Akarsu <eakarsu at gmail.com> wrote: > I think I need one thing. > How can I convert an HTML3 code to proper form? > Let's say I have the number 174 and like convert it to form ® (don't > want &#174;) > how can I get it? > > On Tue, Mar 3, 2015 at 3:48 PM, Erol Akarsu <eakarsu at gmail.com> wrote: > >> Hi, >> >> I need to be able write some special characters into output xml file. I >> have HTTML3 characters like ρ (phase), Δ (delta) in XML. But they >> are printed into xml file as & expanded as "&" >> >> They was being written as >> >> &#961; and &#916; >> >> But I want >> >> ρ and Δ >> >> How can I do it? >> >> Thanks >> >> Erol Akarsu >> >> >
Written for BaseX 8.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery