Subject: Re: [xsl] Generate identifier|
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Dec 2009 10:26:10 -0500
I need to convert a string into an identifier.
Do your identifiers have to be unique or are you allowed to create the same identifier for two different input strings?
Earlier I was using the following function: ... Now, I have to build a name with only containing [A-Za-z0-9] only.
That is very limiting ... the value space for names in XML includes hyphen and underscore, both of which would be handy ... are you sure those two characters are not allowed?
My problem is that I often see characters with modifiers like 00E0 C LATIN SMALL LETTER A WITH GRAVE 00E1 C! LATIN SMALL LETTER A WITH ACUTE 00E2 C" LATIN SMALL LETTER A WITH CIRCUMFLEX 00E3 C# LATIN SMALL LETTER A WITH TILDE 00E4 C$ LATIN SMALL LETTER A WITH DIAERESIS ...
My questions: is it acceptable, from the perspective of a western language, to replace those characters with a character without modifier;
I don't think it is a western language question. Typically identifiers are created to be unique ... if you allow ambiguity, will you still get the transformation results you are expecting for your downstream processes?
is there a way to do this in xslt; any better option?
How about a convention of two identifier characters for every string character, using the second character as a modifier, and some fixed value for "unmodified"?
Thus "abc" would be "a0b0c0" and "dij`" would be "d0eGj0aA" where "G" is for grave and "A" is for acute. With underscore available you could use it as a diacritic introducer, such that "abc" would be "abc" and "dij`" would be "de_Gja_A", thus not changing any string that doesn't have any special characters.
But without knowing more about your constraints, it is difficult to think of what to suggest.
-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal