1 package net.sf.saxon.event; 2 3 import net.sf.saxon.trans.DynamicError; 4 import net.sf.saxon.Configuration; 5 import net.sf.saxon.type.Type; 6 7 11 12 public class NoOpenStartTagException extends DynamicError { 13 14 public static NoOpenStartTagException makeNoOpenStartTagException( 15 int nodeKind, String name, int hostLanguage, boolean topLevel, boolean isSerializing) { 16 String message; 17 String errorCode; 18 if (topLevel) { 19 if (isSerializing) { 20 String kind = (nodeKind == Type.ATTRIBUTE ? "attribute" : "namespace"); 21 message = "Cannot serialize a free-standing " + kind + " node (" + name + ')'; 22 errorCode = (hostLanguage == Configuration.XSLT ? "XTDE0420" : "SENR0001"); 23 } else { 24 String kind = (nodeKind == Type.ATTRIBUTE ? "an attribute" : "a namespace"); 25 message = "Cannot create " + kind + " node (" + name + ") whose parent is a document node"; 26 errorCode = (hostLanguage == Configuration.XSLT ? "XTDE0420" : "XPTY0004"); 27 } 28 } else { 29 String kind = (nodeKind == Type.ATTRIBUTE ? "An attribute" : "A namespace"); 30 message = kind + " node (" + name + ") cannot be created after the children of the containing element"; 31 errorCode = (hostLanguage == Configuration.XSLT ? "XTDE0410" : "XQTY0024"); 32 } 33 NoOpenStartTagException err = new NoOpenStartTagException(message); 34 err.setErrorCode(errorCode); 35 return err; 36 } 37 38 public NoOpenStartTagException(String message) { 39 super(message); 40 } 41 42 61 } 62 63 | Popular Tags |