Executing examples/misc/AddressPrinter under the current JaxMe2 (CVS
HEAD) results in

org.xml.sax.SAXParseException: Unknown attribute: type in namespace 
        at
net.sf.jaxme.impl.JMHandlerImpl.addAttribute(JMHandlerImpl.java:44)
        at
net.sf.jaxme.examples.misc.address.PhoneUnmarshaller.addAttribute(PhoneU
nmarshaller.java:41)
        at
net.sf.jaxme.examples.misc.address.PhoneUnmarshaller.startElement(PhoneU
nmarshaller.java:61)
        at
net.sf.jaxme.examples.misc.address.PhoneDetailsUnmarshaller.startElement
(PhoneDetailsUnmarshaller.java:86)
        at
net.sf.jaxme.examples.misc.address.AddressUnmarshaller.startElement(Addr
essUnmarshaller.java:190)
        at
net.sf.jaxme.impl.JMUnmarshallerHandlerImpl.startElement(JMUnmarshallerH
andlerImpl.java:116)
        at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDis
patcher.dispatch(Unknown Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unkno
wn Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
        at
net.sf.jaxme.impl.JMUnmarshallerImpl.unmarshal(JMUnmarshallerImpl.java:8
1)
        at
net.sf.jaxme.impl.JMUnmarshallerImpl.unmarshal(JMUnmarshallerImpl.java:6
4)
        at AddressPrinter.main(AddressPrinter.java:17)

The reason is that PhoneUnmarshaller's addAttribute doesn't accept
"type" attribute with no prefix therefore no specific namespace.

public void addAttribute(String pURI, String pLocalName, String pValue)
throws SAXException {
    if (pURI == null) { pURI = ""; }
    Phone _1 = (Phone) getResult();
    if ("http://jaxme.sf.net/examples/misc/address".equals(pURI)) {
      if ("type".equals(pLocalName)) {
        _1.setType(pValue);
        return;
      }
    }
    super.addAttribute(pURI, pLocalName, pValue);
  }

I think it's natural to support empty string pURI for this situation
like:

public void addAttribute(String pURI, String pLocalName, String pValue)
throws SAXException {
    if (pURI == null) { pURI = ""; }
    Phone _1 = (Phone) getResult();
    if (
("http://jaxme.sf.net/examples/misc/address".equals(pURI))
||
("".equals(pURI))
)
 {
      if ("type".equals(pLocalName)) {
        _1.setType(pValue);
        return;
      }
    }
    super.addAttribute(pURI, pLocalName, pValue);
  }

This approach can be used to EmailUnmarshaller, which now causes the
same error.

Thanks,

Ias.


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Jaxme-jaxb-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxme-jaxb-dev

Reply via email to