I get the same behavior with a literal value.

            option.addAttribute("value", "&blah");

            if( value.equals(selected) ){
                option.addAttribute("selected", "selected");
            }

            if(one || (first != null && last == null) ) option.setText( 
encodeXML(value) );
            else{
                if(last != null) option.setText( encodeXML( 
DOMTools.trim(rs.getString(last)) ) );
                else option.setText("blah & blah");

produces an XML error with this output:
<option value="&amp;blah">blah & blah</option>


Evan Kirkconnell wrote:
> The database contains: D&G | Dumfries & Galloway Region
>
> With this code, I get an XML parse error because my response type is 
> text/xml, and when I view the source(in FF) I get:
>
> <option value="D&amp;G">Dumfries & Galloway Region</option>
>
> public static String encodeXML(String input){
>         return input;
>         /*
>         StringBuffer sb = new StringBuffer(input);       
>         DOMTools.replace(sb, "&", "&amp;", false);
>         DOMTools.replace(sb, "<", "&lt;", false);
>         DOMTools.replace(sb, ">", "&gt;", false);       
>         return sb.toString();
>         */
>     }
>
> When I take out the comments and do the manual replace then I get &amp;
>
> I would guess that's it has to do with character encoding except that 
> it's working correctly for the value set with addAttribute.  Maybe I'll 
> give it a shot with a literal and see what happens.
>
> --Evan
>
> Edwin Dankert wrote:
>   
>> I can't reproduce your problem ...
>>
>> Document document = DocumentHelper.createDocument();
>> Element element = document.addElement("test");
>>
>> element.setText("<&");
>>      
>> try {
>>   XMLWriter writer = new XMLWriter(System.out);
>>   writer.write(document);
>> } catch (Exception e) {
>>   e.printStackTrace();
>> }
>>
>> Regards,
>> Edwin
>>   
>>     
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>   



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to