[Schematron] Assistance needed with using values as references and more.
Adam De Witt
adewitt at prg.com
Mon Feb 23 10:54:48 EST 2009
Hello all. I am still rather new to Schematron (and XML in general,)
and was wondering if someone could offer me a little guidance with
what I am trying to get accomplished here.
Below is a watered down example of my content:
<profile>
<params>
<param param_name="Alpha" label="Foo" bits="8" channel="1"/>
<param param_name="Beta" label="Bar" bits="16" channel="2"/>
</params>
<values>
<slotted_range param_name="Alpha" id="alpha_list_1" low_limit="0"
high_limit="127">
<for_active_set state="$alpha_list_1_state"/>
<value select="0" id="alpha_list_1_default" label="white"/>
<value select="64" label="red" state="red"/>
</slotted_range>
<slotted_range param_name="Beta" id="beta_list_1" label="adjust
$alpha_list_1_state" low_limit="0" high_limit="32767">
<value select="0" id="beta_list_1_default" label="open"/>
<value select="32767" label="full"/>
</slotted_range>
</values>
</profile>
items to verify:
1)slotted_range/@low_limit and slotted_range/@high_limit are within 8
or 16 bit range as defined by their shared referenced @param_name.
-I have two problems here, figuring out how to use the param_name
value as a reference pointer to another element, and checking the
value of each limit against its possible limits based on the bit
value. Im not even certain the former is possible.
Below is a lame and very flawed attempt at something that would do
this. As im sure is quite obvious, I havent fully grasped XPath yet.
<pattern id="values_within_bitrate">
<rule context="slotted_range/@param_name">
<assert test="(/profile/values/slotted_range/
@param_name[.=current(@param_name)]@bits) = 8 and
(current(@param_name)@high_limit < 255)">
Value out side of param's bitrate</assert>
</rule>
</pattern>
2)Somewhat easier, value/@select must be within their parent
slotted_range/@low_limit and slotted_range/@high_limit.
Below is, once again, my lame attempt at the assertion.
<pattern id="value_selects_within_limits">
<rule context="value/@select">
<assert test="current() <= ../@high_limit">Value is greater than
parent limit</assert>
<assert test="current() >= ../@low_limit">Value is less than
parent limit</assert>
</rule>
</pattern>
3)If a string reference (any token beginning with a $) is found in a
label, it must be defined elsewhere as any attribute value of a
for_active_set element.
-Here my problem is figuring out how to grab just the word starting in
$ to check with. Once again, I cant even discern if this is possible.
Im aware that this architecture isnt exactly best for what im trying
to accomplish, but unfortunately changing the structure isnt an option
due to other applications generating the pieces that get put together
after the fact.
Any assistance would be greatly appreciated, even if its simply
telling me what in this is impossible to accomplish with schematron.
cheers,
-Adam
More information about the Schematron
mailing list