STC in VOResource records

KevinBenson kmb at mssl.ucl.ac.uk
Wed Jan 3 23:45:35 PST 2007


If your doing a reg implementation here is a couple of ways of doing the 
translation.  I recently tested the xsl and seems to work fine, 
currently doing template matches on the  xs:IDREF and xs:ID attributes, 
which seems to be (id, idref, frame_id, coord_system_id) let me know if 
I have missed other attributes.

XSL (sample of @id translates characters to '_' that are not allowed for 
xs:ID it also should catch resubmits in case a user edits&submits the 
xml with the identifier already part of the 'id'.  Also note there are 
probably still a few characters to be translated to '_' that are 
possible from the reg identifier currently did the most commonly seen.)
    <xsl:template match="@id">
       <xsl:variable name="valofattr" select="." />
       <xsl:variable name="valofident" 
select="translate(substring(../../../identifier,7),'.+-/','____')" />
       <xsl:variable name="valofattrsub" 
select="substring($valofattr,1,string-length($valofident))" />

       <xsl:attribute name="id">
       <xsl:if 
test="contains(namespace-uri(..),'http://www.ivoa.net/xml/STC')">
           <xsl:if test="(string-length($valofattrsub) = 0) or 
(string-length($valofattrsub) < string-length($valofident)) or 
(not(contains($valofident,$valofattrsub)))">
       <xsl:value-of select="$valofident" 
/><xsl:text>_</xsl:text></xsl:if></xsl:if><xsl:value-of 
select="$valofattr"/>
       </xsl:attribute>
    </xsl:template>

XSL2.0 and pattern replacing.  If your doing other languages then 
probably you can do simple string replacement with an expression same 
goes with xsl and the replace function.
Here is a sample of a Java one that I used in the past and suspect it 
should work for  other language:
tempIdent.replaceAll("[^\\w*]","_");  //replace all characters that are 
not a 'word' character to "_"



Ray Plante wrote:
> On Wed, 3 Jan 2007, Patrick Dowler wrote:
>> Can we just pick one separator rather than  two optional ones?
>
> It truely doesn't matter as these are opaque string, carrying no other 
> information.  (yes?)  We just have to make sure they are unique.  So 
> if you have a preference, go with it.
>
>> Does this mean
>> these separators should not (cannot) be used within authority id or 
>> resource
>> key or coordsys key?
>
> The existing rules specified in the Identifier spec still apply.  It's 
> just when we use the components from the IVOA ID in this specific 
> case, certain characters that are illegal in the xs:ID context must be 
> translated.
>
> Since multiple characters can get mapped into two characters, this 
> convention is not fail-safe.
>
> cheers,
> Ray



More information about the registry mailing list