Needing help with a Schematron or XPath solution please.

Here should go questions about transforming XML with XSLT and FOP.
William
Posts: 42
Location: London

Needing help with a Schematron or XPath solution please.

Thu Nov 29, 2012 5:11 pm

Hello, is anyone able to help with this, it's making my head hurt!

I have a set of N elements (where N can be in the 1000s) called 'foo' with each having 5 attributes called bar1, bar2, bar3, bar4 and bar5. In addition I also have an attribute (from another set of elements) called minimum and equal to X, where X changes for bar1, bar2 bar3, etc.

Code: Select all

minimum for bar1 = 8
minimum for bar2 = 16
minimum for bar3 = 24
minimum for bar4 = 12
minimum for bar5 = 32

I want to be able to determine if any of the values of the attributes of bar1 (then bar2, etc) change to zero within their value of minimum. So given the following XML :

Code: Select all

<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="145" id='1'/>
<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="145" id='2'/>
<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="145" id='3'/>
<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="145" id='4'/>
<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="135" id='5'/>
<foo bar1="66.56" bar2="44" bar3="518" bar4="0" bar4="135" id='6'/>
<foo bar1="0" bar2="44" bar3="518" bar4="0" bar4="135" id='7'/>
<foo bar1="0" bar2="44" bar3="518" bar4="0" bar4="135" id='8'/>
<foo bar1="0" bar2="44" bar3="518" bar4="0" bar4="135" id='9'/>
<foo bar1="0" bar2="44" bar3="518" bar4="0" bar4="145" id='10'/>

Would be a failure as bar1 changes to 0 on the 7th element.

This is how I see it, Starting at foo position() = 1 I move sideways across the attributes starting with @bar1. I then need to count down @minimum elements to see if any value is zero, then move to position() = 2 and do the same, all the way down the foo elements to position() - @maximum. From here I move on to @bar2 and repeat using the new value for @minimum.

Anyone able to help with either ISO Schematron or XPath 2 or am I asking to much?

--
William

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests