XML Beans - Escape Chars

YesKay <[email protected]>
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <[email protected]>
I'm trying to escaping & char and getting below exception... just wondering
what am I doing wrong? Any help will be greatly appreciated. Here is my
program.

Exception ==>

org.apache.xmlbeans.XmlException: error: Unexpected character encountered
(lex state 3): ' '
	at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3471)
	at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:706)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:690)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:677)
	at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:208)
	at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:633)

Program ==>

public class XMLBeansEscapeChars
{
	public static void main(String[] args)
	{
		try
		{
		String str = "<name>First Name & Last Name</name>";
		
		XmlOptionCharEscapeMap escapes = new XmlOptionCharEscapeMap();
		escapes.addMapping('&', XmlOptionCharEscapeMap.PREDEF_ENTITY);

		XmlOptions xmlOpts = new XmlOptions();
		xmlOpts.setSaveSubstituteCharacters(escapes);
		
		XmlObject xmlObj = XmlObject.Factory.parse(str, xmlOpts);
		
		System.out.println(xmlObj.xmlText());
		}
		catch (Exception ex)
		{		
			ex.printStackTrace();
		}
	}
}

-- 
View this message in context: http://old.nabble.com/XML-Beans---Escape-Chars-tp26813900p26813900.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.