Subject: Re: [xsl] Refactoring parsing code with XSLT 2.0 From: "M. David Peterson" <m.david.x2x2x@xxxxxxxxx> Date: Thu, 12 May 2005 21:36:25 -0600 |
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 whose sole purpose is to seek out a regex pattern to then split the string into substrings... obviously in this case you are only looking for one instance but no matter one or n^x the result will be a sequence of substrings that have been split based on your regular expression. The format for the tokenize() function is tokenize(string, regex, optional regex flag) where the data types are xs:string?, xs:string, and xs:string respectively. As mentioned the result is a sequence whose data type is represented as xs:string* Of course now that you have a sequence you can treat it just like any other sequence and process it further or output it accordingly as you continue through the processing of your stylesheet... sequences, of course, are one of the nifty built-in features courtesy of XPath 2.0, the choice of a new X-enabled generation ;) Cheers :) <M:D/> On 5/12/05, Micah Dubinko <micah@xxxxxxxxxxxx> wrote: > I know how I would do this in XSLT 1.0, and it's not very pretty. Is > there an elegant way in XPath/XSLT 2.0 to do this? > > I have a variable with a string value like "3.48in" or "1pt" or "4" or > "#123456" etc. Of the values that contain units, the first 2 of this > particular list, I want to separate out the value from the units. I can > include a list of possible unit values, say ("in", "cm", "pt", "em", > "px") or whatever. > > I've done XSLT 1.0 for a long time, and am just now getting into 2.0, so > go easy on me. :) I'll post any interesting things I discover in my blog > http://dubinko.info/blog > > Thanks, > > .micah > > -- > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Refactoring parsing code , Aron Bock | Thread | Re: [xsl] Refactoring parsing code , Micah Dubinko |
RE: [xsl] Refactoring parsing code , Aron Bock | Date | Re: [xsl] Using <xsl:for-each> and , Jay Bryant |
Month |