xsl-list
[Top] [All Lists]

RE: Refactoring parsing code with XSLT 2.0

2005-05-13 01:15:20

<xsl:analyze-string select="$in" regex="^(\d*(\.\d*)(in|cm|pt|em|px)$">
 <xsl:matching-substring>
  <measure><xsl:value-of select="regex-group(1)"/></measure>
  <units><xsl:value-of select="regex-group(3)"/></units>
 </xsl:matching-substring>
 <xsl:non-matching-substring>
  <value><xsl:value-of select="."/></value>
 </xsl:non-matching-substring>
</xsl:analyze-string>

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Micah Dubinko [mailto:micah(_at_)dubinko(_dot_)info] 
Sent: 13 May 2005 03:31
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Refactoring parsing code with XSLT 2.0

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(_at_)dubinko(_dot_)info
  Brain Attic, L.L.C.                        http://brainattic.info
  Yahoo IM: mdubinko                                +1 623 298 5172
  Learn XForms today: http://xformsinstitute.com


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--