@@ -612,9 +612,13 @@ public static void writeXml(Object value, String name, XmlStringBuilder builder,
612612 + (addArray ? ARRAY_TRUE : "" ) + " string=\" true\" />" );
613613 } else {
614614 builder .append ("<" + XmlValue .escapeName (name , namespaces )
615- + (addArray ? ARRAY_TRUE : "" ) + ">" );
615+ + (addArray ? ARRAY_TRUE : "" ) + ( name . startsWith ( "?" ) ? " " : ">" ) );
616616 builder .append (escape ((String ) value ));
617- builder .append ("</" + XmlValue .escapeName (name , namespaces ) + ">" );
617+ if (name .startsWith ("?" )) {
618+ builder .append ("?>" );
619+ } else {
620+ builder .append ("</" + XmlValue .escapeName (name , namespaces ) + ">" );
621+ }
618622 }
619623 } else {
620624 processArrays (value , builder , name , parentTextFound , namespaces , addArray );
@@ -709,7 +713,7 @@ public static String escapeName(String name, Set<String> namespaces) {
709713 }
710714 final StringBuilder result = new StringBuilder ();
711715 char ch = name .charAt (0 );
712- if (com .sun .org .apache .xerces .internal .util .XMLChar .isNameStart (ch ) && ch != ':' ) {
716+ if (com .sun .org .apache .xerces .internal .util .XMLChar .isNameStart (ch ) && ch != ':' || ch == '?' ) {
713717 result .append (ch );
714718 } else {
715719 result .append ("__" ).append (Base32 .encode (Character .toString (ch ))).append ("__" );
@@ -989,7 +993,12 @@ private static Object createMap(final org.w3c.dom.Node node,
989993 final org .w3c .dom .NodeList nodeList = node .getChildNodes ();
990994 for (int index = 0 ; index < nodeList .getLength (); index ++) {
991995 final org .w3c .dom .Node currentNode = nodeList .item (index );
992- final String name = currentNode .getNodeName ();
996+ final String name ;
997+ if (currentNode .getNodeType () == org .w3c .dom .Node .PROCESSING_INSTRUCTION_NODE ) {
998+ name = "?" + currentNode .getNodeName ();
999+ } else {
1000+ name = currentNode .getNodeName ();
1001+ }
9931002 final Object value ;
9941003 if (currentNode .getNodeType () == org .w3c .dom .Node .ELEMENT_NODE ) {
9951004 sourceIndex [0 ] = source .indexOf ("<" + name , sourceIndex [0 ]) + name .length () + 1 ;
0 commit comments