[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Generate identifier

Subject: Re: Re: Generate identifier
From: Vyacheslav Sedov <vyacheslav.sedov@xxxxxxxxx>
Date: Thu, 7 Jan 2010 21:37:41 +0300
Re:  Re: Generate identifier
i prefer generate md5 as replacement for name ;)

2010/1/7 Vladimir Nesterovsky <vladimir@xxxxxxxxxxxxxxxxxxxx>:
>> I have missed the original post, but the effect of diacritics
>> is quite different from language to language.
>> Sometimes it is "only" an accent, in other languages it
>> changes the sound and sometimes meaning of a character.
>> What is a "Western" language? If you think of European
>> languages, there are some that do not use ASCII characters
>> at all (Cyrillic, Greek) and your method will not work.
>> So I would just drop them or replace them with an underscore.
>> Saves a lot of energy :-)
>
> You're absolutely right. It's not possible to build a perfect name
> suggestion from a string.
> In my case it's a COBOL name:
> cobol-word = [A-Za-z0-9]+ ([\-]+ [A-Za-z0-9]+)*
>
> And my current implementation is like this:
>
> B <!--
> B  Creates a normalized name for a specified name components.
> B  B  $component - name components to generate normalized name for.
> B  B  $default-name - a default name in case a name cannot be built.
> B  B  Returns a normalized name.
> B -->
> B <xsl:function name="t:create-name" as="xs:string?">
> B  <xsl:param name="components" as="xs:string*"/>
> B  <xsl:param name="default-name" as="xs:string?"/>
>
> B  <xsl:variable name="parts" as="xs:string*">
> B  B  <xsl:for-each select="$components">
> B  B  B  <xsl:analyze-string
> B  B  B  B  regex="[A-Z0-9]+"
> B  B  B  B  flags="imx"
> B  B  B  B  select="
> B  B  B  B  B  replace
> B  B  B  B  B  (
> B  B  B  B  B  B  replace(normalize-unicode(upper-case(.), 'NFD'),
'&#xc6;',
> 'AE'),
> B  B  B  B  B  B  '[\p{Sk}\p{Mc}\p{Me}\p{Mn}]',
> B  B  B  B  B  B  ''
> B  B  B  B  B  )">
> B  B  B  B  <xsl:matching-substring>
> B  B  B  B  B  <xsl:sequence select="."/>
> B  B  B  B  </xsl:matching-substring>
> B  B  B  </xsl:analyze-string>
> B  B  </xsl:for-each>
> B  </xsl:variable>
>
> B  <xsl:sequence select="
> B  B  if (empty($parts)) then
> B  B  B  $default-name
> B  B  else
> B  B  B  string-join
> B  B  B  (
> B  B  B  B  (
> B  B  B  B  B  for
> B  B  B  B  B  B  $i in 1 to count($parts),
> B  B  B  B  B  B  $part in $parts[$i]
> B  B  B  B  B  return
> B  B  B  B  B  B  if (($i = 1) and ($part lt ':') and ($part ge '0')) then
> B  B  B  B  B  B  B  (($default-name, 'N')[1], $part)
> B  B  B  B  B  B  else
> B  B  B  B  B  B  B  $part
> B  B  B  B  ),
> B  B  B  B  '-'
> B  B  B  )"/>
> B </xsl:function>
>
> --
> Vladimir Nesterovsky
> http://www.nesterovsky-bros.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.