Symbol '#' in XML attribute name produses DOMException
Posted
by kilonet
on Stack Overflow
See other posts from Stack Overflow
or by kilonet
Published on 2010-03-30T15:15:09Z
Indexed on
2010/03/31
7:13 UTC
Read the original article
Hit count: 615
the following code (using iText library):
PdfStamper stamp = new PdfStamper(reader, outputStream);
AcroFields form = stamp.getAcroFields();
String name = "form1[0].#subform[0].Table1[0].#subformSet[0].Row[2].#field[0]";
form.setField(name, "");
produces the following error:
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkQName(CoreDocumentImpl.java:2571)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.setName(ElementNSImpl.java:117)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.<init>(ElementNSImpl.java:80)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createElementNS(CoreDocumentImpl.java:2084)
at com.lowagie.text.pdf.XfaForm$Xml2SomDatasets.insertNode(Unknown Source)
at com.lowagie.text.pdf.AcroFields.setField(Unknown Source)
at com.lowagie.text.pdf.AcroFields.setField(Unknown Source)
obviously this is because of '#' sign in field name. This field's name come from AcroFields.getFields() collection and it seems very strange that setting back this value produces an error.
Are there any ways of dealing with this error without changing real field name?
© Stack Overflow or respective owner