Project

Profile

Help

Xpath of invalid child

Added by Anonymous almost 16 years ago

Legacy ID: #5283938 Legacy Poster: Kalyan Moulick (amikalyan)

Hello, I’m very new to xslt programming, and please bear with me if I’m asking a silly question. I’m using Saxon 9SA processor (.NET version), and I’m using Saxon: try block in my xslt to catch invalid node information if any validation error occurred. I found that Saxon call the catch function for the parent element if it contains invalid child. Is it possible to get the xpath or any id of that child element which make the parent invalid in the catch function? For example:. <p xid="01" xpage="26"> <subscrpt xid="02">Valid Element</subscrpt> <p xid="03" >Invalid element which makes parent P Invalid 5</p> <p xid="04" > Invalid element which makes parent P Invalid 5</p> </p> Saxon is throwing the error when it is trying to write the element P (xid="01"). So how to get the xid or xpath of the child element P (xid="03" and xid="04") in the catch block?


Replies (2)

RE: Xpath of invalid child - Added by Anonymous almost 16 years ago

Legacy ID: #5284281 Legacy Poster: Michael Kay (mhkay)

I assume you're using the saxon:try() function documented at http://www.saxonica.com/documentation/extensions/functions/try.html I'm afraid this is a very basic capability; it allows you to recover from errors, but gives you no information about the error that actually occurred. I've recently produced a proposal for a more comprehensive try/catch capability for a future version of the XSLT specification, and hopefully once there are indications of how the W3C WG wants to move on this I will be able to do something more useful in Saxon. Having said that, getting the information you are actually l ooking for - an XPath to the element that failed validation - could be difficult, because the element hasn't actually been constructed yet. Saxon does validation on the fly, while building the tree, so if validation fails, there's no possibility of looking at the unvalidated tree, unless I implement some kind of facility to "keep building but stop validating", which sounds tricky. Michael Kay

RE: Xpath of invalid child - Added by Anonymous almost 16 years ago

Legacy ID: #5284702 Legacy Poster: Kalyan Moulick (amikalyan)

Hi, Thanks for the quick response. It helps me to re-thinking it and solves my purpose by other way.

    (1-2/2)

    Please register to reply