Subject: Selecting an complementary set of nodes From: Ragnar Schierholz <raschi@xxxxxxxxx> Date: Tue, 27 Jun 2000 14:39:09 -0500 |
Hi ! Is it somehow possible to invert the result of node set rsulting from an XPath expression? To be a little more specific, I have a node with multiple children of different element types. One child of one type is mandatory, all the others are optional but can occur in unlimited numbers. In fact, the element type looks somehow like this in the DTD: <!ELEMENT question (stem,(radioMatrix|radioList|checkList|freeText|alphaMatrix|selectList|combination+))> That means a <question> element contains exactly one stem and a child of any of the listed types where the <combination> element can contain any combination of the previous. Thus, as descendants of question, all the other types can occur again. What I need to do is processing the <stem> child first and then later all the other children. What I do currently looks like this: <xsl:template match="question" mode="HTML"> <xsl:variable name="questionIndex"><xsl:value-of select ="number(count(preceding-sibling::question)+1)"/></xsl:variable> <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" BGCOLOR="#A3892A"> <xsl:comment>Begin table question <xsl:value-of select=" @qID"/></xsl:comment> <TR> <TD WIDTH="1%" VALIGN="TOP"> <DIV CLASS="question"> <xsl:value-of select="$questionIndex"/>. </DIV> </TD> <TD> <xsl:apply-templates select="child::stem" mode ="HTML/stem"/> </TD> </TR> <TR> <TD WIDTH="1%"><FONT COLOR="#A3892A">.</FONT></TD> <TD> <xsl:apply-templates select="radioMatrix" mode="HTML"/> <xsl:apply-templates select="radioList" mode="HTML"/> <xsl:apply-templates select="checkList" mode="HTML"/> <xsl:apply-templates select="freeText" mode="HTML"/> <xsl:apply-templates select="alphaMatrix" mode="HTML"/> <xsl:apply-templates select="selectList" mode="HTML"/> <xsl:apply-templates select="combination" mode="HTML"/> </TD> </TR> <xsl:comment>End table question <xsl:value-of select=" @qID"/></xsl:comment> </TABLE> But I am somewhat unhappy with the explicit listing of all children element types because later on, I might want to add some and that would then require to also change this part. Is there a way to select all the children except for those of type <stem>, or in other words the complementary set of children to child::stem? Thanks for your help, Ragnar XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
How to use copy-of with variable? (, Xu, Xiaocun | Thread | Re: Selecting an complementary set , Warren Hedley |
Re: Loading an external file of ind, Paul Tchistopolskii | Date | RE: How to put a page break in XSL?, Xu, Xiaocun |
Month |