DelegatingHandler(ParserDelegate delegate, QName elementName, Handler parent) { this.delegate = delegate; this.parent = parent; this.elementName = elementName; // create a parse tree XSDElementDeclaration e = XSDFactory.eINSTANCE.createXSDElementDeclaration(); e.setTargetNamespace(elementName.getNamespaceURI()); e.setName(elementName.getLocalPart()); ElementImpl instance = new ElementImpl(e); instance.setName(elementName.getLocalPart()); instance.setNamespace(elementName.getNamespaceURI()); parseTree = new NodeImpl(instance); }
/** * Checks if a certain attribute is nil * * @param element * @return */ private boolean isNil(ElementImpl element) { for (AttributeInstance att : element.getAttributes()) { if ("nil".equals(att.getName()) && "http://www.w3.org/2001/XMLSchema-instance".equals(att.getNamespace())) { return "true".equals(att.getText()); } } return false; }
public XSDNamedComponent getDeclaration() { return getElementDeclaration(); }
element = new ElementImpl(content); element.setNamespace(qName.getNamespaceURI()); element.setName(qName.getLocalPart()); element.setAttributes( (AttributeInstance[]) atts.toArray(new AttributeInstance[atts.size()])); for (int i = 0; i < element.getAttributes().length; i++) { AttributeInstance attribute = element.getAttributes()[i]; ParseExecutor executor = new ParseExecutor(attribute, null, parent.getContext(), parser); .walk(element.getElementDeclaration(), initer, container(), parent.getContext());
public ElementInstance element(String text, QName qname) { // create a fake element declaration and element instance XSDElementDeclaration declaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); declaration.setTypeDefinition(xsdSimple(qname.getLocalPart())); ElementInstance element = new ElementImpl(declaration); element.setText(text); return element; }
element.getElementDeclaration(), executor, container(), parser.getLogger().fine("Binding for " + element.getName() + " returned null");
public void characters(char[] ch, int start, int length) throws SAXException { // simply add the text to the element element.addText(ch, start, length); if (isMixed()) { String text = new String(ch, start, length); node.addChild(new NodeImpl(TextInstance.INSTANCE, new Text(text))); } }
public void validateValues( String elementText, int totalDigits, double minExc, double minInc, double maxInc, double maxExc) throws Exception { XSDecimalBinding strat = new XSDecimalBinding(); XSDElementDeclaration declaration = makeDeclaration( totalDigits, new BigDecimal(minExc), new BigDecimal(minInc), new BigDecimal(maxInc), new BigDecimal(maxExc)); ElementInstance element = new ElementImpl(declaration); element.setText(elementText); Node[] children = new Node[] {}; Object value = null; BigDecimal decimal = (BigDecimal) strat.parse(element, element.getText().trim()); assertNotNull(decimal); }
public void startChildHandler(Handler child) { // childHandlers.add(child); node.addChild(child.getParseNode()); // initialize the context for the handler if (child instanceof ElementHandler) { // get the containing type (we do this for anonymous complex types) ElementInstance childInstance = (ElementInstance) child.getComponent(); ContextInitializer initer = new ContextInitializer(childInstance, node, child.getContext()); parser.getBindingWalker() .walk(element.getElementDeclaration(), initer, container(), getContext()); } }