This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Non-well-formed HTML in XSL


> I would like to print HTML that will (eventually) be 
> well-formed. However, the XSL to display it is not 
> well-formed and thus I get an error. What I need is a way to 
> tell XSL to disregard the non-well-formedness of the HTML I'm writing.
> 
>     <xsl:if test="ancestor::node()[position() != 1]">
>       </tr><tr>   # this is the problem
>     </xsl:if>
> 

No, what you need is a better understanding of the XSLT processing
model.

The stylesheet, like the source and result documents, are trees.
<xsl:if> is a node on this tree; if the condition is true, then the
subtree under the <xsl:if> node is evaluated, if not, it is ignored.

Similarly <tr></tr> represents an element node, and in a stylesheet,
this acts as an instruction to construct a <tr/> element on the result
tree.

Now if </tr><tr> means anything, it is half of one node and half of
another, so you're asking xsl:if to evaluate half of one instruction and
half of another. This obviously doesn't make sense.

You've got to change your way of thinking. Instead of thinking abuot
writing start tags and end tags, you've got to structure the stylesheet
around the nodes you want to write. In your case there is a very simple
mapping from source nodes to result nodes, so this isn't at all
difficult.

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com  


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]