Re: [xsl] Refactoring parsing code with XSLT 2.0

Subject: Re: [xsl] Refactoring parsing code with XSLT 2.0
From: "M. David Peterson" <m.david.x2x2x@xxxxxxxxx>
Date: Thu, 12 May 2005 23:20:41 -0600
Doh!  Ok, starting over...  I guess I need to pay better attention to
the problem instead of focusing on what seems to be the obvious
solution and not testing it to immediattelly realize the problem..

anyway, I hate to admit it but it seems that in this particular
situation you are simply looking for a test pattern that can be any
number of test patterns contained within a given sequence... the way
to test is using the fn:contains of which you you would use
fn:substring-before to extract from the string the piece that is
representing the value, or in other words, the same thing you would do
in 1.0.

However, you do have conditional logic within XPath now which allows
you to utlize the "for" expression coupled with "in" and "return", for
establishing the fact that you plan to iterate through a given
sequence that is represented by a variable and set using the "in"
expression to point to a specific sequence via a typical XPath
expression.  return, of course would then return a sequence containing
the result of your expression...

This may have already been obvious and therefore nothing exciting but
in regards to this problem the conditional logic in your XPath is
about  as exciting as I think this ones gonna get... but then again,
with as much as XPath 2.0 and XSLT 2.0 brings to the party I most
definitely have not thought through all of the possibilities that
exist so maybe there is and its just not occuring to me at the
moment...


On 5/12/05, Micah Dubinko <micah@xxxxxxxxxxxx> wrote:
> Thanks,
>
> I've used tokenize, and I like it. But it seems to only work where you
> can throw away the delimiters.
>
> Ex.  "a b c" --> "a", "b", "c" (with the spaces gone)
>
> In this case, what I need is
>
> "3.04in" --> "3.04", "in"
>
> So I'd need a regex that hits in the right spot, but matches zero
> characters. I don't think lookaheads are in the spec. At least I haven't
> found them. Neither are subexpressions that I can tell.
>
> I still have a feeling that XSLT2 offers some elegant way to do this, at
> least more elegant than my current 11-line <xsl:choose> construction. Am
> I off-key?
>
> .micah
>
> M. David Peterson wrote:
>
> >Micah,
> >
> >Do you want to potentially keep track of what goes with what... in
> >other words do you want to walk away with a set of elements that have
> >the value, unit short name, and unit long name for example...
> >
> >Actually, no matter what your desired output is in 2.0 this type of
> >functionality is serviced via the tokenize() function
> >
> >
>
> --
>  Available for consulting. XForms, web forms, information overload.
>  Micah Dubinko                           mailto:micah@xxxxxxxxxxxx
>  Brain Attic, L.L.C.                        http://brainattic.info
>  Yahoo IM: mdubinko                                +1 623 298 5172
>  Learn XForms today: http://xformsinstitute.com
>
>


--
<M:D/>

:: M. David Peterson ::
XML & XML Transformations, C#, .NET, and Functional Languages Specialist

Current Thread