| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.event; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.expr.parser.Location; |
| 12 |
import net.sf.saxon.lib.StandardErrorListener; |
| 13 |
import net.sf.saxon.trans.XPathException; |
| 14 |
import net.sf.saxon.type.Type; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public class NoOpenStartTagException extends XPathException { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public static NoOpenStartTagException makeNoOpenStartTagException( |
| 36 |
int nodeKind, String name, int hostLanguage, boolean parentIsDocument, |
| 37 |
Location startElementLocationId) { |
| 38 |
String message; |
| 39 |
String errorCode; |
| 40 |
if (parentIsDocument) { |
| 41 |
String kind = nodeKind == Type.ATTRIBUTE ? "an attribute" : "a namespace"; |
| 42 |
message = "Cannot create " + kind + " node (" + name + ") whose parent is a document node"; |
| 43 |
errorCode = hostLanguage == Configuration.XSLT ? "XTDE0420" : "XPTY0004"; |
| 44 |
} else { |
| 45 |
String kind = nodeKind == Type.ATTRIBUTE ? "An attribute" : "A namespace"; |
| 46 |
message = kind + " node (" + name + ") cannot be created after a child of the containing element"; |
| 47 |
errorCode = hostLanguage == Configuration.XSLT ? "XTDE0410" : "XQTY0024"; |
| 48 |
} |
| 49 |
if (startElementLocationId != null && startElementLocationId.getLineNumber() != -1) { |
| 50 |
message += ". Most recent element start tag was output at line " + |
| 51 |
startElementLocationId.getLineNumber() + " of module " + |
| 52 |
StandardErrorListener.abbreviatePath(startElementLocationId.getSystemId()); |
| 53 |
} |
| 54 |
NoOpenStartTagException err = new NoOpenStartTagException(message); |
| 55 |
err.setErrorCode(errorCode); |
| 56 |
return err; |
| 57 |
} |
| 58 |
|
| 59 |
public NoOpenStartTagException(String message) { |
| 60 |
super(message); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
} |
| 65 |
|