public String getTextStringValue(Object obj) { if ( obj instanceof Text ) { return ((Text)obj).getText(); } if ( obj instanceof CDATA ) { return ((CDATA)obj).getText(); } return ""; }
/** * This will handle printing of <code>{@link CDATA}</code> text. * * @param cdata <code>CDATA</code> to output. * @param out <code>Writer</code> to use. */ protected void printCDATA(Writer out, CDATA cdata) throws IOException { String str=(currentFormat.mode == Format.TextMode.NORMALIZE) ? cdata.getTextNormalize() : ((currentFormat.mode == Format.TextMode.TRIM) ? cdata.getText().trim() : cdata.getText()); out.write("<![CDATA["); out.write(str); out.write("]]>"); }
public String getElementStringValue(Object obj) { Element elem = (Element) obj; StringBuffer buf = new StringBuffer(); List content = elem.getContent(); Iterator contentIter = content.iterator(); Object each = null; while ( contentIter.hasNext() ) { each = contentIter.next(); if ( each instanceof Text ) { buf.append( ((Text)each).getText() ); } else if ( each instanceof CDATA ) { buf.append( ((CDATA)each).getText() ); } else if ( each instanceof Element ) { buf.append( getElementStringValue( each ) ); } } return buf.toString(); }
/** * This will handle printing of <code>{@link CDATA}</code> text. * * @param cdata <code>CDATA</code> to output. * @param out <code>Writer</code> to use. */ protected void printCDATA(Writer out, CDATA cdata) throws IOException { String str = (currentFormat.mode == Format.TextMode.NORMALIZE) ? cdata.getTextNormalize() : ((currentFormat.mode == Format.TextMode.TRIM) ? cdata.getText().trim() : cdata.getText()); out.write("<![CDATA["); out.write(str); out.write("]]>"); }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getTextTrim()); if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getValue()); if (node instanceof CDATA) return Collections.singletonList(((CDATA) node).getText()); if (node instanceof Comment) return Collections.singletonList(((Comment) node).getText()); if (node instanceof ProcessingInstruction) return Collections.singletonList(((ProcessingInstruction) node).getData()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_text can not be applied on " + node.getClass()); } }
/** * This will handle printing of <code>{@link CDATA}</code> text. * * @param cdata <code>CDATA</code> to output. * @param out <code>Writer</code> to use. */ protected void printCDATA( Writer out, CDATA cdata ) throws IOException { String str = ( currentFormat.mode == Format.TextMode.NORMALIZE ) ? cdata.getTextNormalize() : ( ( currentFormat.mode == Format.TextMode.TRIM ) ? cdata.getText().trim() : cdata.getText() ); out.write( "<![CDATA[" ); out.write( str ); out.write( "]]>" ); }
@Override String getText(Object node) { if (node instanceof Element) { return ((Element) node).getTextTrim(); } if (node instanceof Attribute) { return ((Attribute) node).getValue(); } if (node instanceof CDATA) { return ((CDATA) node).getText(); } if (node instanceof Comment) { return ((Comment) node).getText(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction) node).getData(); } return null; }
/** * This returns a <code>String</code> representation of the * <code>CDATA</code> node, suitable for debugging. If the XML * representation of the <code>CDATA</code> node is desired, * either <code>{@link #getText}</code> or * {@link org.jdom.output.XMLOutputter#output(CDATA, java.io.Writer)}</code> * should be used. * * @return <code>String</code> - information about this node. */ public String toString() { return new StringBuffer(64) .append("[CDATA: ") .append(getText()) .append("]") .toString(); } }
/** * This will create an <code>Exception</code> indicating * that the addition of the <code>{@link CDATA}</code> * * @param base <code>Element</code> that the <code>CDATA</code> * couldn't be added to * @param added <code>CDATA</code> that could not be added * @param reason cause of the problem */ IllegalAddException(Element base, CDATA added, String reason) { super(new StringBuffer() .append("The CDATA \"") .append(added.getText()) .append("\" could not be added as content to \"") .append(base.getQualifiedName()) .append("\": ") .append(reason) .toString()); }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getTextTrim()); if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getValue()); if (node instanceof CDATA) return Collections.singletonList(((CDATA) node).getText()); if (node instanceof Comment) return Collections.singletonList(((Comment) node).getText()); if (node instanceof ProcessingInstruction) return Collections.singletonList(((ProcessingInstruction) node).getData()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_text can not be applied on " + node.getClass()); } }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getTextTrim()); if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getValue()); if (node instanceof CDATA) return Collections.singletonList(((CDATA) node).getText()); if (node instanceof Comment) return Collections.singletonList(((Comment) node).getText()); if (node instanceof ProcessingInstruction) return Collections.singletonList(((ProcessingInstruction) node).getData()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_text can not be applied on " + node.getClass()); } }
private void normaliseLineEndings( Document document ) { for ( Iterator<?> i = document.getDescendants( new ContentFilter( ContentFilter.COMMENT ) ); i.hasNext(); ) { Comment c = (Comment) i.next(); c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); } for ( Iterator<?> i = document.getDescendants( new ContentFilter( ContentFilter.CDATA ) ); i.hasNext(); ) { CDATA c = (CDATA) i.next(); c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); } }
String getText(Object node) { if (node instanceof Element) { return ((Element)node).getTextTrim(); } if (node instanceof Attribute) { return ((Attribute)node).getValue(); } if (node instanceof CDATA) { return ((CDATA)node).getText(); } if (node instanceof Comment) { return ((Comment)node).getText(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction)node).getData(); } return null; }
@Override String getText(Object node) { if (node instanceof Element) { return ((Element) node).getTextTrim(); } if (node instanceof Attribute) { return ((Attribute) node).getValue(); } if (node instanceof CDATA) { return ((CDATA) node).getText(); } if (node instanceof Comment) { return ((Comment) node).getText(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction) node).getData(); } return null; }
@Override String getText(Object node) { if (node instanceof Element) { return ((Element) node).getTextTrim(); } if (node instanceof Attribute) { return ((Attribute) node).getValue(); } if (node instanceof CDATA) { return ((CDATA) node).getText(); } if (node instanceof Comment) { return ((Comment) node).getText(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction) node).getData(); } return null; }
CDATA cdata = (CDATA) node; org.w3c.dom.CDATASection domCdata = domDoc.createCDATASection(cdata.getText()); domElement.appendChild(domCdata);
public List operate(Object node) { if (node instanceof Element) return Collections12.singletonList(((Element)node).getTextTrim()); if (node instanceof Attribute) return Collections12.singletonList(((Attribute)node).getValue()); if (node instanceof CDATA) return Collections12.singletonList(((CDATA)node).getText()); if (node instanceof Comment) return Collections12.singletonList(((Comment)node).getText()); if (node instanceof ProcessingInstruction) return Collections12.singletonList(((ProcessingInstruction)node).getData()); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_text can not be applied on " + node.getClass()); } }
cdata(((CDATA) node).getText());