OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Re: help with xslt


Sam Steingold wrote:

> > concat('sec_', translate(substring-before(substring-after(
> > '#(11 1 2 1 2)', '#('), ')'), ' ', '-'))

> cool - this takes care of the old version (sec_11-1-2-1-2).
> how about 11_abab?

    concat(
      substring-after(
        substring-before('#(11 1 2 1 2)', ' '),
        '#('),
      '_',
      translate(
        substring-before(
          substring-after('#(11 1 2 1 2)', ' '),
          ')'),
        '123456789 ',
        'abcdefghi'))

  You can see both in the following XQuery, for what is worth:

    let $in := '#(11 1 2 1 2)'
    let $nums := substring-before(substring-after($in, '#('), ')')
    let $old := concat('sec_', translate($nums, ' ', '-'))
    let $letters := translate(substring-after($nums, ' '),
                              '123456789 ', 'abcdefghi')
    let $new := concat(substring-before($nums, ' '), '_', $letters)
      return
        <res>
          <old>{ $old }</old>
          <new>{ $new }</new>
        </res>

    ==>

    <?xml version="1.0" encoding="UTF-8"?>
    <res>
       <old>sec_11-1-2-1-2</old>
       <new>11_abab</new>
    </res>

  This works only if you have digits from 1 to 9.  If you can
have 10+, I think you would parse $nums to integers then map
integers to letters.  And definitively write a function to
encapsulate and document the funtionality.

  Regards,

--drkm





















      


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]