Discussion:
xml condition
(too old to reply)
today
2016-04-15 17:08:01 UTC
Permalink
Is any better way to express this condition which is to detect words in a table that have some ending, group them together in a class and colorize the columns in a particular color and highlight the lines that fall under the condition.
Thanks in advance

<IF>
<CONDITIONS>
<condition col="x" line="2" operator="and" line="4" TextEnd="e"></condition>
<condition col="x" line="5" operator="and" line="6" TextEnd="a"></condition>
<condition col="x" line="10" TextEnd="er"></condition>
</CONDITIONS>
<RESULTS><Create Class1/></RESULTS>
<ELSE>
<RESULTS><Color="class1" color="Blue"/></RESULTS>
</ELSE>
<ELSE>
<RESULTS><Color="lines" highlight color="NavyBlue"/></RESULTS>
</ELSE>
</IF>


<IF>
<CONDITIONS>
<condition col="x" line="2" operator="and" line="4" TextEnd="e"></condition>
<condition col="x" line="5" operator="and" line="6" operator="and" line="11" TextEnd="i"></condition>
<condition col="x" line="10" TextEnd="er"></condition>
</CONDITIONS>
<RESULTS><Create Class2/></RESULTS>
<ELSE>
<RESULTS><Color="class2" color="Blue"/></RESULTS>
</ELSE>
<ELSE>
<RESULTS><Color="lines" highlight color="NavyBlue"/></RESULTS>
</ELSE>
</IF>
Peter Flynn
2016-04-16 22:53:11 UTC
Permalink
Post by today
Is any better way to express this condition
Yes. Use XPath in a language like XSLT2.
Post by today
which is to detect words in a table that have some ending, group them
together in a class
You mean change their position in the output?
Post by today
and colorize the columns in a particular color and highlight the
lines that fall under the condition.
You must post some sample data that this can be tested on. It is
impossible to understand your example, because we cannot see the
input, and your condition elements are not referred to in your results,
so it is impossible to see which of them is being applied.
Post by today
<IF>
<CONDITIONS>
<condition col="x" line="2" operator="and" line="4" TextEnd="e"></condition>
<condition col="x" line="5" operator="and" line="6" TextEnd="a"></condition>
<condition col="x" line="10" TextEnd="er"></condition>
</CONDITIONS>
If I understand this right,

<xsl:template match="something which matches lines 2 and 4 and col x">
<xsl:choose>
<xsl:when test="ends-with(.,'e') or
ends-with(.,'a') or
ends-with(.,'er')">
-- do something --
</xsl:when>
<xsl:otherwise>
-- do something else --
</xsl:otherwise>
</xsl:template>

But you need to provide us with a LOT more information.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Loading...