[jdom-interest] hex v. dec

Joe Bowbeer joe.bowbeer at gmail.com
Wed Oct 20 12:49:56 PDT 2004


FWIW, you could also plug-in a different outputter.

The XMLWriter in jdom's samples uses decimal notation.  So does
dom4j's XMLWriter.  Once you have a document, either of these can be
plugged into jdom's SAXOutputter.

For my simple test below, I plug dom4j's XMLWriter directly into
SAXBuilder, using the XMLFilter hook.  In this way, SAXBuilder drives
the parser and sends SAX events to the XMLWriter for output.

import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.dom4j.io.XMLWriter;

public class Test {
    public static void main(String[] args) throws Exception {
        SAXBuilder builder = new SAXBuilder();
        XMLWriter writer = new XMLWriter();
        writer.setMaximumAllowedCharacter(127);
        builder.setXMLFilter(writer);
        java.io.InputStream in = Test.class.getResourceAsStream("test.xml");
        Document doc = builder.build(in);
    }
}

<?xml version="1.0" encoding="UTF-8"?>
<eConnect xmlns:dt="urn:schemas-microsoft-com:datatypes">
<SMCustomerMasterType>
  <taUpdateCreateCustomerRcd>
  <!-- <snip/> -->
    <ADDRESS1>Villa Espa&#241;a Zaragoza</ADDRESS1>
  <!-- <snip/> -->
  </taUpdateCreateCustomerRcd>
</SMCustomerMasterType>
</eConnect>


Note: If you don't set maximum allowed character, you'll get an "enya"
instead of &#241;


On Tue, 19 Oct 2004 19:07:39 -0600, Mark C. Stafford <obbyyoyo at gmail.com> wrote:
> Hello,
> 
> I'm working with MySQL and Microsoft's Great Plains (Pains). GP is not
> happy with unicode characters unless they're escaped *using decimal
> notation*. Neither have I succeeded in defining an ENTITY that it
> accepts.
> 
> I've implemented an EscapeStrategy which is working well, but have not
> found a property or method that will allow me to choose to "degrade"
> the encoding.
> 
> &#xf1; crashes, but &#241; (tested by hand) works.
> 
> I'm holding up a data conversion. Can you help me? Is this the right
> place to ask? I thought I'd check before resorting to some sort of
> String-based re-parsing with regexp...
> 
> Thanks,
> 
> Mark
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <eConnect xmlns:dt="urn:schemas-microsoft-com:datatypes">
>  <SMCustomerMasterType>
>    <taUpdateCreateCustomerRcd>
>    <!-- <snip/> -->
>      <ADDRESS1>Villa Espa&#xf1;a Zaragoza</ADDRESS1>
>    <!-- <snip/> -->
>    </taUpdateCreateCustomerRcd>
>  </SMCustomerMasterType>
> </eConnect>
>


More information about the jdom-interest mailing list