xsl-list
[Top] [All Lists]

Re: [xsl] Generate identifier

2009-12-29 10:26:54
At 2009-12-29 07:13 -0800, Vladimir Nesterovsky wrote:
I need to convert a string into an identifier.

Does that string include white-space?

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 Ã  LATIN SMALL LETTER A WITH GRAVE
00E1 á LATIN SMALL LETTER A WITH ACUTE
00E2 â LATIN SMALL LETTER A WITH CIRCUMFLEX
00E3 ã LATIN SMALL LETTER A WITH TILDE
00E4 ä 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 "déjà" 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 "déjà" 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.

I hope this gives you some ideas.

. . . . . . . . . . Ken

--
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(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>