[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: An element's value is an invalid Unicode string ... how ca
At 2013-01-04 18:26 +0000, Costello, Roger L. wrote: >Consider this Spanish name: Martiñez > >Instead of using the ñ character, one can use >the (base) "n" character followed by a combining tilde (hex 303) character. Perhaps one can do that for display purposes, but I would think linguists would challenge you. The letter in the Spanish alphabet is a fully-formed letter on its own, it is not an accented "n", so if you compose it as an accented "n" then you aren't representing the Spanish letter. There are 27 (or 29) letters in the Spanish alphabet: http://spanish.about.com/cs/forbeginners/a/beg_alphabet.htm >So that Spanish name can be equivalently expressed as: Martiñez I disagree, but let's continue with your discussion. >Here is an XML document that uses the latter form: > ><?xml version="1.0" encoding="utf-8"?> ><Name>Martiñez</Name> > >I wrote a stylesheet that uses the substring() >function to extract the combining tilde character and onward: > > <xsl:template match="/"> > <Result> > <xsl:value-of select="substring(Name, 7)" /> > </Result> > </xsl:template> > >The output is: > ><?xml version="1.0" encoding="UTF-8"?> ><Result>Þez</Result> > >I checked it for well-formedness and the XML Parser says it is well-formed. Correct ... because there are no restrictions on the Unicode *characters* that can be included in an element that state an element cannot begin with a diacritic. >According to the book, Fonts & Encodings (p. 61, first paragraph): > > ... we select a substring that begins > with a combining character, this new > string will not be a valid string in > Unicode. > >The value of the <Result> element is not a valid >Unicode string, so how can it be a well-formed XML document? Because well-formedness is not defined by strings, but by characters: Ref: [39] http://www.w3.org/TR/2008/REC-xml-20081126/#NT-element [39] element ::= EmptyElemTag | STag content ETag Ref: [43] http://www.w3.org/TR/2008/REC-xml-20081126/#NT-content [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* Ref: [14] http://www.w3.org/TR/2008/REC-xml-20081126/#NT-CharData [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) I see nothing there that states a diacritic cannot be the first character of character data. Well-formedness is defined from the perspective of reading characters. Well-formedness does not involve interpreting the content of an element represented by those characters. It would be up to an application to complain that the content is not as expected, not the XML processor. What if I wanted to have the following: <allowed-diacritics> <diacritic>į</diacritic> </allowed-diacritics> Why would an XML processor be obligated to tell me that that is not well-formed? I hope this is helpful. . . . . . . . . . Ken -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/ G. Ken Holman mailto:gkholman@CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|