protected void augmentOptions() { Step decl = declaration; if (decl == null) { throw new UnsupportedOperationException("Unexpected step type: " + getType()); } Hashtable<QName,Option> declOptions = new Hashtable<QName,Option> (); for (Option option : decl.options()) { declOptions.put(option.getName(), option); } // Add any options that have default values... for (QName oname : declOptions.keySet()) { Option doption = declOptions.get(oname); Option option = getOption(oname); if (option == null) { if (doption.getSelect() != null || doption.getBinding().size() != 0) { addOption(doption); } } else { option.setType(doption.getType(), doption.getNode()); // copy the type over } } }
private void xmlReport(Option option) { String type = option.getType(); boolean req = option.getRequired(); String select = option.getSelect(); pr.print(" <option name='" + option.getName().getClarkName() + "' required='" + req + "'"); if (type != null) { pr.print(" type='" + type + '"'); } if (select != null) { pr.print(" select=\"" + select.replaceAll("\"",""") + "\""); } pr.println("/>"); }
public boolean valid(Environment env) { boolean valid = true; if (bindings.size() > 1) { error("Option can have at most one binding.", XProcConstants.dynamicError(8)); valid = false; } if (required && (select != null)) { error("You can't specify a default value on a required option", XProcConstants.staticError(17)); } return valid; }
public void addOption(Option option) { // FIXME: Is it worth making a hash for this? QName optName = option.getName(); for (Option exoption : options) { if (optName.equals(exoption.getName())) { error(option.getNode(),"Duplication option name: " + optName,XProcConstants.staticError(4)); } } options.add(option); }
value = optionsPassedIn.get(name); } else { if (option.getRequired() && option.getSelect() == null) { throw XProcException.staticError(18, option.getNode(), "No value provided for required option \"" + option.getName() + "\""); if (option.getSelect() == null) { value = new RuntimeValue(); } else {
private Option readOption(Step parent, XdmNode node) { checkAttributes(node, new String[] { "name", "required", "select" }, false); String name = node.getAttributeValue(new QName("name")); String required = node.getAttributeValue(new QName("required")); String select = node.getAttributeValue(new QName("select")); String type = node.getAttributeValue(XProcConstants.cx_type); if (name == null) { throw XProcException.staticError(38, node, "Attribute \"name\" required on p:with-option"); } QName oname; if (name.contains(":")) { oname = new QName(name, node); } else { oname = new QName(name); } if (XProcConstants.NS_XPROC.equals(oname.getNamespaceURI())) { throw XProcException.staticError(28, node, "You cannot specify an option in the p: namespace."); } if (required != null && !"false".equals(required) && !"true".equals(required)) { throw XProcException.staticError(19, node, "The required attribute must be 'true' or 'false'."); } Option option = new Option(runtime, node); option.setName(oname); option.setRequired(required); option.setSelect(select); option.setType(type, node); readNamespaceBindings(parent, option, node, select); checkExtensionAttributes(node, option); return option; }
.getName().getNamespaceURI(), option.getName() .getLocalName(), option.getName().getPrefix()), option.getRequired(), option.getSelect()));
valid = valid && p.valid(env); QName pName = p.getName(); if (pName == null) { valid = false; if (doption.getRequired()) { if (getOption(doption.getName()) == null) { valid = false; error("Required option not specified: " + doption.getName(), XProcConstants.staticError(18)); Option doption = decl.getOption(option.getName()); if (doption == null) { if (getVersion() > 1.0) { error("Undeclared option specified: " + option.getName(), XProcConstants.staticError(10));
Option option = new Option(runtime, node); option.setName(new QName("", aname.getLocalName())); option.setSelect("'" + attr.getStringValue().replace("'", "''") + "'"); option.addNamespaceBinding(new NamespaceBinding(step.getXProc(),node));
protected void dump(int depth) { String indent = ""; for (int count = 0; count < depth; count++) { indent += " "; } if (select != null) { logger.trace(indent + "option " + getName() + " select=" + select); } else { logger.trace(indent + "option " + getName()); if (getBinding().size() == 0) { if (XProcConstants.p_option.equals(node.getNodeName())) { // System.err.println(indent + " no binding allowed"); } else { logger.trace(indent + " no binding"); } } } for (Binding binding : getBinding()) { binding.dump(depth+2); } } }
public List<QName> getOptions() { Vector<QName> names = new Vector<QName> (); for (Option option : options) { names.add(option.getName()); } return names; }
option.dump(depth+2);
if (XProcConstants.p_with_option.equals(option.getNode().getNodeName())) { if (!checkOptionBinding(option, true)) { valid = false;
for (Binding binding : option.getBinding()) { if (binding.getBindingType() == Binding.PIPE_NAME_BINDING) { PipeNameBinding pipe = (PipeNameBinding) binding;
value = optionsPassedIn.get(name); } else { if (option.getRequired() && option.getSelect() == null) { throw XProcException.staticError(18, option.getNode(), "No value provided for required option \"" + option.getName() + "\""); if (option.getSelect() == null) { value = new RuntimeValue(); } else {
private Option readOption(Step parent, XdmNode node) { checkAttributes(node, new String[] { "name", "required", "select" }, false); String name = node.getAttributeValue(new QName("name")); String required = node.getAttributeValue(new QName("required")); String select = node.getAttributeValue(new QName("select")); String type = node.getAttributeValue(XProcConstants.cx_type); if (name == null) { throw XProcException.staticError(38, node, "Attribute \"name\" required on p:with-option"); } QName oname; if (name.contains(":")) { oname = new QName(name, node); } else { oname = new QName(name); } if (XProcConstants.NS_XPROC.equals(oname.getNamespaceURI())) { throw XProcException.staticError(28, node, "You cannot specify an option in the p: namespace."); } if (required != null && !"false".equals(required) && !"true".equals(required)) { throw XProcException.staticError(19, node, "The required attribute must be 'true' or 'false'."); } Option option = new Option(runtime, node); option.setName(oname); option.setRequired(required); option.setSelect(select); option.setType(type, node); readNamespaceBindings(parent, option, node, select); checkExtensionAttributes(node, option); return option; }
valid = valid && p.valid(env); QName pName = p.getName(); if (pName == null) { valid = false; if (doption.getRequired()) { if (getOption(doption.getName()) == null) { valid = false; error("Required option not specified: " + doption.getName(), XProcConstants.staticError(18)); Option doption = decl.getOption(option.getName()); if (doption == null) { if (getVersion() > 1.0) { error("Undeclared option specified: " + option.getName(), XProcConstants.staticError(10));
Option option = new Option(runtime, node); option.setName(new QName("", aname.getLocalName())); option.setSelect("'" + attr.getStringValue().replace("'", "''") + "'"); option.addNamespaceBinding(new NamespaceBinding(step.getXProc(),node));
public void addOption(Option option) { // FIXME: Is it worth making a hash for this? QName optName = option.getName(); for (Option exoption : options) { if (optName.equals(exoption.getName())) { error(option.getNode(),"Duplication option name: " + optName,XProcConstants.staticError(4)); } } options.add(option); }