/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'"; }
/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'"; }
/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { computeUriAndLocal(); return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'&&q.local==='" + localName + "'"; }
/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { computeUriAndLocal(); return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'&&q.local==='" + localName + "'"; }
/** * Generate Javascript code to test whether an item conforms to this item type * * @return a Javascript instruction or sequence of instructions, which can be used as the body * of a Javascript function, and which returns a boolean indication whether the value of the * variable "item" is an instance of this item type. * @param knownToBe An item type that the supplied item is known to conform to; the generated code * can assume that the item is an instance of this type. * @param targetVersion The version of Saxon-JS for which code is being generated. Currently either 1 or 2. */ @Override public String generateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion) { if (targetVersion == 1) { return "var q=SaxonJS.U.nameOfNode(item); return SaxonJS.U.isNode(item) && item.nodeType===" + nodeKind + "&&" + generateJavaScriptNameTest(targetVersion); } else { return "return SaxonJS.U.isNode(item) && item.nodeType===" + nodeKind + " && SaxonJS.U.hasURI(item, '" + ExpressionPresenter.jsEscape(uri) + "');"; } }
/** * Generate Javascript code to test whether an item conforms to this item type * * @return a Javascript instruction or sequence of instructions, which can be used as the body * of a Javascript function, and which returns a boolean indication whether the value of the * variable "item" is an instance of this item type. * @param knownToBe An item type that the supplied item is known to conform to; the generated code * can assume that the item is an instance of this type. * @param targetVersion The version of Saxon-JS for which code is being generated. Currently either 1 or 2. */ @Override public String generateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion) { if (targetVersion == 1) { return "var q=SaxonJS.U.nameOfNode(item); return SaxonJS.U.isNode(item) && item.nodeType===" + nodeKind + "&&" + generateJavaScriptNameTest(targetVersion); } else { return "return SaxonJS.U.isNode(item) && item.nodeType===" + nodeKind + " && SaxonJS.U.hasURI(item, '" + ExpressionPresenter.jsEscape(uri) + "');"; } }
return "return " + instNode + "SaxonJS.U.hasLocalName(item,'" + localName + "')&&SaxonJS.U.hasURI(item,'" + ExpressionPresenter.jsEscape(uri) + "')";
return "return " + instNode + "SaxonJS.U.hasLocalName(item,'" + localName + "')&&SaxonJS.U.hasURI(item,'" + ExpressionPresenter.jsEscape(uri) + "')";