[Design of JBossXB] - Re: How to force strict validation?
by alex.loubyansky@jboss.com
W/o changing APIs you could do something like this:
final String xsd =
| "<xsd:schema" +
| " xmlns:jbxb='http://www.jboss.org/xml/ns/jbxb'" +
| " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
| " <xsd:element name='root' type='root-type'/>" +
| " <xsd:complexType name='root-type'>" +
| " <xsd:annotation>" +
| " <xsd:appinfo>" +
| " <jbxb:class impl='" + E.class.getName() + "'/>" +
| " </xsd:appinfo>" +
| " </xsd:annotation>" +
| " <xsd:attribute name='unqualified' type='xsd:string' use='required'/>" +
| " </xsd:complexType>" +
| "</xsd:schema>";
|
| String xml = "<root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='testns'/>";
|
| org.xml.sax.EntityResolver resolver = new org.xml.sax.EntityResolver()
| {
| public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
| {
| if(systemId != null && systemId.endsWith("testns"))
| return new org.xml.sax.InputSource(new StringReader(xsd));
| return null;
| }
| };
|
| /*
| Validator.assertValidXml(xml, new org.xml.sax.EntityResolver()
| {
| public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
| {
| if(systemId != null && systemId.endsWith("testns"))
| return new org.xml.sax.InputSource(new StringReader(xsd));
| return null;
| }
| });
| */
|
| SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
| Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
| unmarshaller.setEntityResolver(resolver);
| unmarshaller.setSchemaValidation(true);
|
| Object o = unmarshaller.unmarshal(new StringReader(xml), schema);
| assertTrue(o instanceof E);
This will throw the exception you expect. The difference is that I had to add noNamespaceSchemaLocation into the xml instead of setting it on the parser.
It might still be useful to expose setProperty() or the parser itself though.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133243#4133243
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133243
16 years, 6 months
[Design the new POJO MicroContainer] - Domain resolve algorithm
by alesj
What's the status of this:
- http://jira.jboss.com/jira/browse/JBMICROCONT-182
| protected Object resolve(Controller controller, Module module, Requirement requirement)
| {
| // TODO JBMICROCONT-182 include parent domains in requirements
| // TODO JBMICROCONT-182 check consistency of re-exports
| // TODO JBMICROCONT-182 check for self-dependency
| // TODO JBMICROCONT-182 test circularity
|
I'm just asking, since after reading this
- http://www.osgi.org/blog/2008/02/research-challenges-for-osgi.html
I started thinking about the challenge
- http://post-office.corp.redhat.com/mailman/private/jboss-osgi-dev-list/20...
in more mathematical fashion, providing some concrete proof for the actual algorithm used, time usage wise. It boils down to graph theory, and finding some known problem to 'map' this usage to it.
A quick thought.
How does re-wiring stand against the actual ClassLoader usage.
e.g. we already have wired bundles, and we want to add a new one. But with the current wiring that is not possible (possibly some 'uses' constraints in the way), but if we re-wire things, we might be able to wire the new bundle as well.
I guess that means uninstalling current deployments, and installing them back on after we 'discovered' that there is a wire configuration that makes everyone happy. :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133233#4133233
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133233
16 years, 6 months