My XML Data should look like this:
<mixed_type_parent>
...text...
<other_element1/>
<other_element2/>
<element_in_question>...some content...</element_in_question>
<other_element2>...text...</other_element2>
<other_element1>...text...</other_element1>
...text...
</mixed_type_parent>
What I want to make sure using Schematron is that the "element_in_question" may only appear within "mixed_type_parent" if there is some text outside of the "element_in_question". That means
<mixed_type_parent>
<element_in_question>...some content...</element_in_question>
</mixed_type_parent>
is not allowed and should cause an error.
I tried to get the string-length of all text immediately within "mixed_type_parent"
string-length(replace(ancestor::mixed_type_parent[1]/text(),' ', ''))
But, again, there is one of the most annoying errors in XPath: "A sequence of more than one item is not allowed as the first argument of replace()"
In XSLT I have solved this problem by the simplest function you can think about:
<xsl:function name="locfun:make_string">
<xsl:param name="input_sequence"/>
<xsl:value-of select="$input_sequence"/>
</xsl:function>
(It is really a shame that there seams to be no such built-in function in XPath.)
But how can I use this function in Schematron? I didn't find a solution for this.
And other than that: How do I get all text form all other childs of "mixed_type_parent" except "mixed_type_parent"?
Try this:
string-join(ancestor::mixed_type_parent[1]/text(),'')=''
For your second question: How do I get all text form all other childs of "mixed_type_parent" except "mixed_type_parent"?
/mixed_type_parent/*[not(self::element_in_question)]/text()