public void populate(Element parent) { if (requireCdata) { parent.addContent(new CDATA(valueString())); } else { parent.setText(valueString()); } }
/** * This will handle printing of a {@link CDATA}. * * @param fstack * the FormatStack * @param basedoc * The org.w3c.dom.Document for creating DOM Nodes * @param cdata * <code>CDATA</code> to write. * @return The input JDOM CDATA converted to a DOM CDATASection */ protected org.w3c.dom.CDATASection printCDATA(final FormatStack fstack, final org.w3c.dom.Document basedoc, final CDATA cdata) { // CDATAs are treated like text, not indented/newline content. return basedoc.createCDATASection(cdata.getText()); }
/** * This constructor creates a new <code>CDATA</code> node, with the * supplied string value as it's character content. * * @param string the node's character content. * @throws IllegalDataException if <code>str</code> contains an * illegal character such as a vertical tab (as determined * by {@link org.jdom2.Verifier#checkCharacterData}) * or the CDATA end delimiter <code>]]></code>. */ public CDATA(final String string) { super(CType.CDATA); setText(string); }
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 ) ); } }
/** * This will append the content of another <code>Text</code> node * to this node. * * @param text Text node to append. */ @Override public void append(final Text text) { // Overrides Text.append(Text) because this needs to check that CDATA // rules are enforced. We could have a separate Verifier check for CDATA // beyond Text and call that alone before super.setText(). if (text == null) { return; } append(text.getText()); }
@Override public CDATA cdata(final int line, final int col, final String str) { CDATA c = new CDATA(); c.value = str; return c; }
/** * This will handle printing of a {@link CDATA}. * * @param out * <code>XMLStreamWriter</code> to use. * @param fstack * the FormatStack * @param cdata * <code>CDATA</code> to write. * @throws XMLStreamException * if the destination XMLStreamWriter fails */ protected void printCDATA(final XMLStreamWriter out, final FormatStack fstack, final CDATA cdata) throws XMLStreamException { // CDATAs are treated like text, not indented/newline content. out.writeCData(cdata.getText()); }
@Override public CDATA cdata(final int line, final int col, final String text) { return new CDATA(text); }
/** * 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.jdom2.output.XMLOutputter#output(CDATA, java.io.Writer)}</code> * should be used. * * @return <code>String</code> - information about this node. */ @Override public String toString() { return new StringBuilder(64) .append("[CDATA: ") .append(getText()) .append("]") .toString(); }
@Override public void process(final XMLStreamWriter out, final Format format, final CDATA cdata) throws XMLStreamException { final List<CDATA> list = Collections.singletonList(cdata); final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); if (walker.hasNext()) { final Content c = walker.next(); if (c == null) { printCDATA(out, fstack, new CDATA(walker.text())); } else if (c.getCType() == CType.CDATA) { printCDATA(out, fstack, (CDATA)c); } } out.flush(); }
/** * This will handle printing of a {@link CDATA}. * * @param out * <code>Writer</code> to use. * @param fstack * the FormatStack * @param cdata * <code>CDATA</code> to write. * @throws IOException * if the destination Writer fails */ protected void printCDATA(final Writer out, final FormatStack fstack, final CDATA cdata) throws IOException { // CDATAs are treated like text, not indented/newline content. textCDATA(out, cdata.getText()); }
@Override public void process(final XMLEventConsumer out, final Format format, final XMLEventFactory eventfactory, final CDATA cdata) throws XMLStreamException { final List<CDATA> list = Collections.singletonList(cdata); final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); if (walker.hasNext()) { final Content c = walker.next(); if (c == null) { printCDATA(out, fstack, eventfactory, new CDATA(walker.text())); } else if (c.getCType() == CType.CDATA) { printCDATA(out, fstack, eventfactory, (CDATA)c); } } }
/** * 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 StringBuilder() .append("The CDATA \"") .append(added.getText()) .append("\" could not be added as content to \"") .append(base.getQualifiedName()) .append("\": ") .append(reason) .toString()); }
@Override public org.w3c.dom.CDATASection process(org.w3c.dom.Document basedoc, Format format, CDATA cdata) { final List<CDATA> list = Collections.singletonList(cdata); final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); if (walker.hasNext()) { final Content c = walker.next(); if (c == null) { return printCDATA(fstack, basedoc, new CDATA(walker.text())); } if (c.getCType() == CType.CDATA) { return printCDATA(fstack, basedoc, (CDATA)c); } } // return an empty string if nothing happened. return null; }
/** * This will handle printing of a {@link CDATA}. * * @param out * <code>XMLEventConsumer</code> to use. * @param fstack * the FormatStack * @param eventfactory * The XMLEventFactory for creating XMLEvents * @param cdata * <code>CDATA</code> to write. * @throws XMLStreamException * if the destination XMLEventConsumer fails */ protected void printCDATA(final XMLEventConsumer out, final FormatStack fstack, final XMLEventFactory eventfactory, final CDATA cdata) throws XMLStreamException { // CDATAs are treated like text, not indented/newline content. out.add(eventfactory.createCData(cdata.getText())); }
n = printCDATA(fstack, basedoc, new CDATA(text)); } else { n = printText(fstack, basedoc, new Text(text));
/** * This will handle printing of a {@link CDATA}. * * @param out * <code>SAXTarget</code> to use. * @param fstack * the FormatStack * @param cdata * <code>CDATA</code> to write. * @throws SAXException * if the destination SAXTarget fails */ protected void printCDATA(final SAXTarget out, final FormatStack fstack, final CDATA cdata) throws SAXException { // CDATAs are treated like text, not indented/newline content. final LexicalHandler lexicalHandler = out.getLexicalHandler(); final char[] chars = cdata.getText().toCharArray(); if (lexicalHandler != null) { lexicalHandler.startCDATA(); out.getContentHandler().characters(chars, 0, chars.length); lexicalHandler.endCDATA(); } else { out.getContentHandler().characters(chars, 0, chars.length); } }
printCDATA(out, fstack, new CDATA(walker.text())); } else { printText(out, fstack, new Text(walker.text()));
printCDATA(out, fstack, eventfactory, new CDATA(walker.text())); } else { printText(out, fstack, eventfactory, new Text(walker.text()));
public List<Element> toXmlValues( final String valueElementName, final PwmSecurityKey pwmSecurityKey ) { final List<Element> returnList = new ArrayList<>(); for ( final String value : this.values ) { final Element valueElement = new Element( valueElementName ); valueElement.addContent( new CDATA( value ) ); returnList.add( valueElement ); } return returnList; }