private static void writeUnclosedElement(SAXElement element, Writer writer, boolean encodeSpecialChars) throws IOException { QName name = element.getName(); String prefix = name.getPrefix(); writer.write('<'); if(prefix != null && !prefix.equals(XMLConstants.NULL_NS_URI)) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); writeAttributes(element.getAttributes(), writer, encodeSpecialChars); }
private static void writeUnclosedElement(SAXElement element, Writer writer, boolean encodeSpecialChars) throws IOException { QName name = element.getName(); String prefix = name.getPrefix(); writer.write('<'); if(prefix != null && !prefix.equals(XMLConstants.NULL_NS_URI)) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); writeAttributes(element.getAttributes(), writer, encodeSpecialChars); }
private static void writeUnclosedElement(SAXElement element, Writer writer, boolean encodeSpecialChars) throws IOException { QName name = element.getName(); String prefix = name.getPrefix(); writer.write('<'); if(prefix != null && !prefix.equals(XMLConstants.NULL_NS_URI)) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); writeAttributes(element.getAttributes(), writer, encodeSpecialChars); }
private static void writeUnclosedElement(SAXElement element, Writer writer, boolean encodeSpecialChars) throws IOException { QName name = element.getName(); String prefix = name.getPrefix(); writer.write('<'); if(prefix != null && !prefix.equals(XMLConstants.NULL_NS_URI)) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); writeAttributes(element.getAttributes(), writer, encodeSpecialChars); }
private void addNamespace(String prefix, String namespaceURI, SAXElement element) { if (prefix == null || namespaceURI == null) { // No namespace. Ignore... return; } else if(prefix.equals(XMLConstants.DEFAULT_NS_PREFIX) && namespaceURI.equals(XMLConstants.NULL_NS_URI)) { // No namespace. Ignore... return; } else { String prefixNS = element.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix); if(prefixNS != null && prefixNS.length() != 0) { // Already declared (on the element)... return; } } Attributes attributes = element.getAttributes(); AttributesImpl attributesCopy = new AttributesImpl(); attributesCopy.setAttributes(attributes); if(prefix.length() > 0) { attributesCopy.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, "xmlns:" + prefix, null, namespaceURI); } else { attributesCopy.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, "xmlns", null, namespaceURI); } element.setAttributes(attributesCopy); } }
private void addNamespace(String prefix, String namespaceURI, SAXElement element) { if (prefix == null || namespaceURI == null) { // No namespace. Ignore... return; } else if(prefix.equals(XMLConstants.DEFAULT_NS_PREFIX) && namespaceURI.equals(XMLConstants.NULL_NS_URI)) { // No namespace. Ignore... return; } else { String prefixNS = element.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix); if(prefixNS != null && prefixNS.length() != 0) { // Already declared (on the element)... return; } } Attributes attributes = element.getAttributes(); AttributesImpl attributesCopy = new AttributesImpl(); attributesCopy.setAttributes(attributes); if(prefix.length() > 0) { attributesCopy.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, "xmlns:" + prefix, null, namespaceURI); } else { attributesCopy.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, "xmlns", null, namespaceURI); } element.setAttributes(attributesCopy); } }
public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException { if(isAttribute) { bindValue(SAXUtil.getAttribute(valueAttributeName, element.getAttributes()), executionContext, new Fragment(element)); } else { // Turn on Text Accumulation... element.accumulateText(); } }
public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException { if(isAttribute) { bindValue(SAXUtil.getAttribute(valueAttributeName, element.getAttributes()), executionContext, new Fragment(element)); } else { // Turn on Text Accumulation... element.accumulateText(); } }
public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException { if(isAttribute) { bindValue(SAXUtil.getAttribute(valueAttributeName, element.getAttributes()), executionContext, new Fragment(element)); } else { // Turn on Text Accumulation... element.accumulateText(); } }
private void bindSaxDataValue(SAXElement element, ExecutionContext executionContext) { String dataString; if (isAttribute) { dataString = SAXUtil.getAttribute(valueAttributeName, element.getAttributes()); } else { dataString = element.getTextContent(); } if(expression != null) { bindExpressionValue(executionContext); } else { populateAndSetPropertyValue(dataString, executionContext); } }
SAXElement newElement = new SAXElement(qName, element.getAttributes(), element.getParent()); newElement.setWriter(element.getWriter(this), this);
SAXElement newElement = new SAXElement(qName, element.getAttributes(), element.getParent()); newElement.setWriter(element.getWriter(this), this);
private void bindSaxDataValue(SAXElement element, ExecutionContext executionContext) { String propertyName; if(mapKeyAttribute != null) { propertyName = SAXUtil.getAttribute(mapKeyAttribute, element.getAttributes(), null); if(propertyName == null) { propertyName = element.getName().getLocalPart(); } } else if(property != null) { propertyName = property; } else { propertyName = element.getName().getLocalPart(); } String dataString = null; if(expressionEvaluator == null || expressionHasDataVariable) { if (isAttribute) { if(valueAttributeNS != null) { dataString = SAXUtil.getAttribute(valueAttributeNS, valueAttributeName, element.getAttributes(), null); } else { dataString = SAXUtil.getAttribute(valueAttributeName, element.getAttributes(), null); } } else { dataString = element.getTextContent(); } } if(expressionEvaluator != null) { bindExpressionValue(propertyName, dataString, executionContext, new Fragment(element)); } else { decodeAndSetPropertyValue(propertyName, dataString, executionContext, new Fragment(element)); } }
SAXElement newElement = new SAXElement(qName, element.getAttributes(), element.getParent()); newElement.setWriter(element.getWriter(this), this);
SAXElement newElement = new SAXElement(qName, element.getAttributes(), element.getParent()); newElement.setWriter(element.getWriter(this), this);
private void bindSaxDataValue(SAXElement element, ExecutionContext executionContext) { String propertyName; if(mapKeyAttribute != null) { propertyName = SAXUtil.getAttribute(mapKeyAttribute, element.getAttributes(), null); if(propertyName == null) { propertyName = element.getName().getLocalPart(); } } else if(property != null) { propertyName = property; } else { propertyName = element.getName().getLocalPart(); } String dataString = null; if(expressionEvaluator == null || expressionHasDataVariable) { if (isAttribute) { if(valueAttributeNS != null) { dataString = SAXUtil.getAttribute(valueAttributeNS, valueAttributeName, element.getAttributes(), null); } else { dataString = SAXUtil.getAttribute(valueAttributeName, element.getAttributes(), null); } } else { dataString = element.getTextContent(); } } if(expressionEvaluator != null) { bindExpressionValue(propertyName, dataString, executionContext, new Fragment(element)); } else { decodeAndSetPropertyValue(propertyName, dataString, executionContext, new Fragment(element)); } }
private void bindSaxDataValue(SAXElement element, ExecutionContext executionContext) { String propertyName; if(mapKeyAttribute != null) { propertyName = SAXUtil.getAttribute(mapKeyAttribute, element.getAttributes(), null); if(propertyName == null) { propertyName = element.getName().getLocalPart(); } } else if(property != null) { propertyName = property; } else { propertyName = element.getName().getLocalPart(); } String dataString = null; if(expressionEvaluator == null || expressionHasDataVariable) { if (isAttribute) { if(valueAttributeNS != null) { dataString = SAXUtil.getAttribute(valueAttributeNS, valueAttributeName, element.getAttributes(), null); } else { dataString = SAXUtil.getAttribute(valueAttributeName, element.getAttributes(), null); } } else { dataString = element.getTextContent(); } } if(expressionEvaluator != null) { bindExpressionValue(propertyName, dataString, executionContext, new Fragment(element)); } else { decodeAndSetPropertyValue(propertyName, dataString, executionContext, new Fragment(element)); } }