/** * Generates SAX events for this ValidationError. In case of the constructors where * a String error message key was supplied, the necessary I18n tags will be generated. */ public void generateSaxFragment(ContentHandler contentHandler) throws SAXException { if (this.saxFragment != null) { this.saxFragment.toSAX(contentHandler); } }
public void generateDisplayData(String name, ContentHandler contentHandler) throws SAXException { Object data = this.displayData.get(name); if (data != null) { ((XMLizable) data).toSAX(contentHandler); } else if (!this.displayData.containsKey(name)) { throw new IllegalArgumentException("Unknown display data name '" + name + "'"); } }
public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException { Iterator i = messages.iterator(); while (i.hasNext()) { XMLizable message = (XMLizable) i.next(); contentHandler.startElement(FormsConstants.INSTANCE_NS, MESSAGE_EL, FormsConstants.INSTANCE_PREFIX_COLON + MESSAGE_EL, XMLUtils.EMPTY_ATTRIBUTES); message.toSAX(contentHandler); contentHandler.endElement(FormsConstants.INSTANCE_NS, MESSAGE_EL, FormsConstants.INSTANCE_PREFIX_COLON + MESSAGE_EL); } }
public void generateDisplayData(ContentHandler contentHandler) throws SAXException { // Output all non-null display data Iterator iter = this.displayData.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); if (entry.getValue() != null) { String name = (String) entry.getKey(); // Enclose the data into a "wi:{name}" element contentHandler.startElement(FormsConstants.INSTANCE_NS, name, FormsConstants.INSTANCE_PREFIX_COLON + name, XMLUtils.EMPTY_ATTRIBUTES); ((XMLizable) entry.getValue()).toSAX(contentHandler); contentHandler.endElement(FormsConstants.INSTANCE_NS, name, FormsConstants.INSTANCE_PREFIX_COLON + name); } } }
private void sourceToSAX(Source source, ContentHandler handler) throws SAXException, IOException, ProcessingException { if (source instanceof XMLizable) { ((XMLizable) source).toSAX(handler); } else { this.saxParser.parse(SourceUtil.getInputSource(source), handler); } }
private void sourceToSAX(Source source, ContentHandler handler) throws SAXException, IOException, SourceException, ProcessingException { if (source instanceof XMLizable) { ((XMLizable) source).toSAX(handler); } else { this.saxParser.parse(SourceUtil.getInputSource(source), handler); } }
public void generateSaxFragment(ContentHandler contentHandler, Locale locale, Convertor.FormatCache formatCache) throws SAXException { String stringValue; if (this.value == null) { stringValue = ""; } else { stringValue = datatype.getConvertor().convertToString(this.value, locale, formatCache); } AttributesImpl attrs = new AttributesImpl(); attrs.addCDATAAttribute("value", stringValue); contentHandler.startElement(FormsConstants.INSTANCE_NS, ITEM_EL, FormsConstants.INSTANCE_PREFIX_COLON + ITEM_EL, attrs); contentHandler.startElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES); if (this.label == null) { contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length()); } else if (this.label instanceof XMLizable) { ((XMLizable) this.label).toSAX(contentHandler); } else { String stringLabel = (String) this.label; contentHandler.characters(stringLabel.toCharArray(), 0, stringLabel.length()); } contentHandler.endElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL); contentHandler.endElement(FormsConstants.INSTANCE_NS, ITEM_EL, FormsConstants.INSTANCE_PREFIX_COLON + ITEM_EL); } }
public void generateSaxFragment(ContentHandler contentHandler, Locale locale, Convertor.FormatCache formatCache) throws SAXException { String stringValue; if (this.value != null) { stringValue = getDatatype().getConvertor().convertToString(this.value, locale, formatCache); } else { // Null value translates into the empty string stringValue = ""; } AttributesImpl attrs = new AttributesImpl(); attrs.addCDATAAttribute("value", stringValue); contentHandler.startElement(FormsConstants.INSTANCE_NS, ITEM_EL, FormsConstants.INSTANCE_PREFIX_COLON + ITEM_EL, attrs); contentHandler.startElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES); if (this.label == null) { contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length()); } else if (this.label instanceof XMLizable) { ((XMLizable) this.label).toSAX(contentHandler); } else { String stringLabel = (String) this.label; contentHandler.characters(stringLabel.toCharArray(), 0, stringLabel.length()); } contentHandler.endElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL); contentHandler.endElement(FormsConstants.INSTANCE_NS, ITEM_EL, FormsConstants.INSTANCE_PREFIX_COLON + ITEM_EL); } }
public static void executeNode(final XMLConsumer consumer, Object val, boolean stripRoot) throws SAXException { if (val instanceof Node) { executeDOM(consumer, (Node) val, stripRoot); } else if (val instanceof NodeList) { NodeList nodeList = (NodeList) val; int len = nodeList.getLength(); for (int i = 0; i < len; i++) { Node n = nodeList.item(i); //TODO: should this take stripRoot into account? executeDOM(consumer, n); } } else if (val instanceof Node[]) { Node[] nodeList = (Node[]) val; int len = nodeList.length; for (int i = 0; i < len; i++) { Node n = nodeList[i]; //TODO: should this take stripRoot into account? executeDOM(consumer, n); } } else if (val instanceof XMLizable) { IncludeXMLConsumer includer = new IncludeXMLConsumer(consumer); includer.setIgnoreRootElement(stripRoot); ((XMLizable) val).toSAX(includer); } else { char[] ch = val == null ? ArrayUtils.EMPTY_CHAR_ARRAY : val .toString().toCharArray(); consumer.characters(ch, 0, ch.length); } }
contentHandler.startElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES); if (label instanceof XMLizable) { ((XMLizable)label).toSAX(contentHandler); } else if( this.labelIsI18nKey ) { String stringLabel = label.toString();
contentHandler.startElement(FormsConstants.INSTANCE_NS, LABEL_EL, FormsConstants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES); if (label instanceof XMLizable) { ((XMLizable)label).toSAX(contentHandler); } else if( this.labelIsI18nKey ) { String stringLabel = label.toString();
contentHandler.startElement(FormsConstants.INSTANCE_NS, MARKER_EL, FormsConstants.INSTANCE_PREFIX_COLON + MARKER_EL, attributesImpl); contentHandler.startElement(FormsConstants.INSTANCE_NS, MARKER_TEXT_EL, FormsConstants.INSTANCE_PREFIX_COLON + MARKER_TEXT_EL, new AttributesImpl()); marker.getText().toSAX(contentHandler); contentHandler.endElement(FormsConstants.INSTANCE_NS, MARKER_TEXT_EL, FormsConstants.INSTANCE_PREFIX_COLON + MARKER_TEXT_EL); contentHandler.endElement(FormsConstants.INSTANCE_NS, MARKER_EL, FormsConstants.INSTANCE_PREFIX_COLON + MARKER_EL);
handler.startElement(EXCEPTION_NS, "content", "ex:content", attr); if (current instanceof XMLizable) { ((XMLizable) current).toSAX(handler);
((XMLizable) source).toSAX(serializer); } else { final String mimeType = source.getMimeType();