Subject: RE: [xsl] Newbie: Extracting and evaluating partial values from elements From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 22 Oct 2007 17:46:38 +0100 |
It's easy enough even in XSLT 1.0. Assuming the relevant bit_position is the context node, <td colspan="{number(substring-after(., ':')) - number(substring-before(., ':'))}"> If you're using Saxon 6.5.5, then there's really no reason not to use Saxon 8.9 and take advantage of XSLT 2.0, which makes a lot of things much easier. Though it doesn't make much difference in this case. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Jeff Hooker [mailto:jeff@xxxxxxxxxxxx] > Sent: 22 October 2007 17:32 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Newbie: Extracting and evaluating partial > values from elements > > Hi all, > > I'm trying to take 32-bit registers that have been documented > as follows: > > <?xml version="1.0" encoding="UTF-8"?> > <register> > <bit_postion>31:12</bit_postion> > <bit_postiont>11:9</bit_postion> > <bit_postion>8</bit_postion> > <bit_postion>7</bit_postion> > <bit_postion>6:1</bit_postion> > <bit_postion>0</bit_postion> > </register> > > and turn them into a 32-column table where the number of bits > in each <bit_position> element is popluated into the a > colspan tag. This means that the first bit element would > result in <td colspan="19">, the third bit_position element > would result in <colspan='1'>, etc. > > Getting the values out of the single-entry elements is easy; > if there's no colon, I know it only contains a single bit. > Getting the values when there IS a colon is driving me nuts. > I need to to extract the values, determine the difference, > and populate the colspan, and XSL's handling of > variables/parameters is very new and unfamiliar to me. Any > pointers on a good approach would be much apprecitated; > everything I've tried so far has ended up chasing its tail, > logically speaking. > > I'm using Saxon 6.5.5, but would prefer to avoid using > extensions if possible. > > Thanks in advance for any guidance. > > (Yes, I know that that could have been avoided by adding > something like optional <high_value> and <low_value> elements > to the <bit_position> element, but the horses left the barn > on that one 6 years ago.)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Newbie: Extracting and ev, David Carlisle | Thread | [xsl] Text replacement using "recur, TeleServices |
Re: [xsl] Newbie: Extracting and ev, David Carlisle | Date | Re: [xsl] Newbie: Extracting and ev, Andrew Welch |
Month |