xml - In a Schematron rule, how do i access the parent element of the current element? -


i using iso schematron validate xml document. rule have set works required, want report name of parent element context of assertion fired. sample document might contain xml fragment:

<name>alan smith<br/></name>

my schematron rule tests <br/> element allowed occur child of <title> element. rule follows:

<rule context="br">     <assert test="parent::title"      >the "br" element not allowed child of '<iso:value-of select=".."/>' element.'</assert> </rule> 

when run rule against fragment, assertion correctly fired, want message tell me "the "br" element not allowed child of 'name' element". instead shows "the "br" element not allowed child of 'alan smith' element". <iso:value-of select=".."/> expression selecting text node , not parent element expected? can explain xppath expression should using in select statement display name of parent element in error message?. thanks.

update: managed achieve desired result removing select statement, , replacing name element in:

<rule context="br">     <assert test="parent::title"      >the "br" element not allowed child of '<name path=".."/>' element.'</assert> </rule> 

so problem solved, if can explain why first attempt doesn't work, helpful.

that how value-of element works. http://www.schematron.com/iso/p8.html#gen16

value-of element

finds or calculates values instance document allow clearer assertions , diagnostics. required select attribute expression evaluated in current context returns string.

variable references in select attribute resolved in scope of current schema, phase, pattern , rule.

an implementation not report natural-language assertions not required make use of element.

you can name of context node's parent xpath expression.

name(..) 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -