I have an attribute which is only valid if the length is 0, 2 or 3 characters. Anything invalid must be either converted to a 0 length string or omitted entirely.

Now, I've thought of three ways to do this, which do you think is the easiest to follow and which is most efficent?
I'm leaning towards the last one. Anyone got better suggestions?

1. do-reformat-op-attr and xpath

<do-reformat-op-attr name="Attr1">
<arg-value type="string">
<token-xpath expression="$current-value[string-length(.)=2 or string-length(.)=3]"/>
</arg-value>
</do-reformat-op-attr>


2. do-reformat-op-attr and replace-first

<do-reformat-op-attr name="Attr1">
<arg-value type="string">
<token-replace-first regex="^(.?|.{4,})$" replace-with="">
<token-local-variable name="current-value"/>
</token-replace-first>
</arg-value>
</do-reformat-op-attr>

3. do-strip-xpath

<do-strip-xpath expression=".//value[ancestor-or-self::*[@attr-name='Attr1'] and (string-length(.)&lt;2 or string-length(.)>3)]"/>

--
If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...