xsl-list
[Top] [All Lists]

RE: [xsl] Newbie: Extracting and evaluating partial values from elements

2007-10-22 09:47:28
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(_at_)itwriting(_dot_)ca] 
Sent: 22 October 2007 17:32
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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.)

--~------------------------------------------------------------------
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>
--~--