Refine search
public void endNode() { try { if (!children) { Element element = new DefaultElement((String)elementStack.pop()); for (int i = 0; i < attributes.getLength(); ++i) { element.addAttribute(attributes.getQName(i), attributes.getValue(i)); } writer.write(element); attributes.clear(); children = true; // node just closed is child of node on top of stack started = true; } else { startElement(); writer.endElement("", "", (String)elementStack.pop()); } } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
public void add(Attribute attribute) { if (attribute.getParent() != null) { String message = "The Attribute already has an existing parent \"" + attribute.getParent().getQualifiedName() + "\""; throw new IllegalAddException(this, attribute, message); } if (attribute.getValue() == null) { // try remove a previous attribute with the same // name since adding an attribute with a null value // is equivalent to removing it. Attribute oldAttribute = attribute(attribute.getQName()); if (oldAttribute != null) { remove(oldAttribute); } } else { if (attributes == null) { attributes = attribute; } else { attributeList().add(attribute); } childAdded(attribute); } }
public void setText(String text) { validate(text); super.setText(text); }
public Object clone() { DefaultElement answer = (DefaultElement) super.clone(); if (answer != this) { answer.content = null; answer.attributes = null; answer.appendAttributes(this); answer.appendContent(this); } return answer; }
public Attribute attribute(String name, Namespace namespace) { return attribute(getDocumentFactory().createQName(name, namespace)); }
public static Document createErrorDocument( String errorMsg ) { Element rootElement = new DefaultElement( "web-service" ); Document doc = DocumentHelper.createDocument( rootElement ); rootElement.addElement( "error" ).addAttribute( "msg", StringEscapeUtils.escapeXml( errorMsg ) ); return doc; }
if (null != expDoc) { Document doc = expDoc.getDocument(); Element system = doc.getRootElement().element(ExportConstants.SYSTEM_TAG); if (null != system) { DefaultElement lcpolicy = (DefaultElement) system.element(ExportConstants.LIFECYCLE_POLICY_TAG); DefaultElement lcs = (DefaultElement) system.element(ExportConstants.LIFECYCLE_STATE_TAG); if (null != lcs && LifeCycleConstants.DELETED_STATE.equals(lcs.getTextTrim())) { while (null != itr && itr.hasNext()) { DefaultElement facet = (DefaultElement) itr.next(); String value = facet.getTextTrim(); if (FacetNames.IMMUTABLE.equals(value)) { && (null != lcpolicy && !"documentRouteElement".equals(lcpolicy.getTextTrim())) ) { lcs.setText(initialLifeCycleState);
/** * {@inheritDoc} */ @Override public Element toDsml( Element root ) { Element element; if ( root != null ) { element = root.addElement( COMPARE_RESPONSE_TAG ); } else { element = new DefaultElement( COMPARE_RESPONSE_TAG ); } LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(), getDecorated().getLdapResult(), getDecorated() ); ldapResultDsml.toDsml( element ); return element; }
public Element createElement(QName qname) { return new DefaultElement(qname); }
private static Element createSoapElement( String name, String value ) { Element element = new DefaultElement( name ); element.addCDATA( value ); return element; }
public static void main(String[] args) throws DocumentException { SAXReader reader = new SAXReader(); String xml = "<div class=\"discussionThread dt\"><div class=\"dt_subject\">2011 IS HERE!</div></div>"; Document document = reader.read(new StringReader(xml)); DefaultElement newElement = new DefaultElement("div"); newElement.addAttribute("class", "test"); newElement.add(new DefaultText("Test Val")); List content = document.getRootElement().content(); if (content != null ) { content.add(0, newElement); } System.out.println(document.asXML()); }
public void testCreateXPathBug() throws Exception { Element element = new DefaultElement("foo"); XPath xpath = element.createXPath("//bar"); assertTrue(("created a valid XPath: " + xpath) != null); }
Attribute copy = attribute(attribute.getQName()); childRemoved(attribute);
protected void addNode(Node node) { super.addNode(node); if ((elementIndex != null) && node instanceof Element) { addToElementIndex((Element) node); } else if ((attributeIndex != null) && node instanceof Attribute) { addToAttributeIndex((Attribute) node); } }
public Element addText(String text) { validate(text); return super.addText(text); }
public List<Attribute> attributes() { return new ContentListFacade<Attribute>(this, attributeList()); }
public static Document createStatusDocument( String statusMsg ) { Element rootElement = new DefaultElement( "web-service" ); Document doc = DocumentHelper.createDocument( rootElement ); rootElement.addElement( "status" ).addAttribute( "msg", StringEscapeUtils.escapeXml( statusMsg ) ); return doc; } }
/** * {@inheritDoc} */ @Override public Element toDsml( Element root ) { Element element; if ( root != null ) { element = root.addElement( MODIFY_RESPONSE_TAG ); } else { element = new DefaultElement( MODIFY_RESPONSE_TAG ); } LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(), getDecorated().getLdapResult(), getDecorated() ); ldapResultDsml.toDsml( element ); return element; } }
public Element createElement(QName qname) { return new DefaultElement(qname); }
private static Element createSoapElement( String name, List value ) { Element element = new DefaultElement( name ); element.addCDATA( value.toString() ); return element; }