users@jaxb.java.net

SCD and custom elements

From: Warren Crossing <warren.crossing_at_mofokom.biz>
Date: Fri, 24 Apr 2009 08:35:02 +0200

I can confirm that this still happens with jaxbri2.1.11 the latest xsom
nightly. -nv has no impact. forest mode is now used by default. I did
debug the xjc and tried attaching the xmlns on the actual binding node.

You will see the problem in the example -
https://hj3.dev.java.net/svn/hj3/trunk/ejb/tests/po-customized - if you
use scd on PurchaseOrderType.

I tried to debug the xjc to watch the construction of the scd targets,
(it appears on application of offending target - parent is null) also
tried declaring the namespace on the target nodes in the .xsd.

I have to use the bindings file and scd is a superior form of addressing.

Your thoughts.

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of
element 'hj:entity'.
         at
com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Util.java:109)
         at
com.sun.org.apache.xerces.internal.jaxp.validation.ErrorHandlerAdaptor.error(ErrorHandlerAdaptor.java:104)
         at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
         at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
         at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1944)
         at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
         at
com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:335)
         at
com.sun.tools.xjc.util.ForkContentHandler.startElement(ForkContentHandler.java:110)
         at
org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
         at
com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:141)
         at
com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:239)
         at
com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
         at
com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
         at
com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet$Target.apply(SCDBasedBindingSet.java:180)
         at
com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet$Target.applyAll(SCDBasedBindingSet.java:138)
         at
com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet$Target.access$700(SCDBasedBindingSet.java:82)
         at
com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:237)
         at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:522)
         at
com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:375)
         at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
         at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
         at
org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630)
         at
org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258)
         at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134)
         at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
         at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
         at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
         at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


We do have several tests for using SCD in the external binding file. The
error seems to be a bug in the validation --- there certailny is no
element declaration for <hj:table>, and it's meant to be skipped.

Can you run XJC with -mode forest? That might give me some info. Also
does -nv makes any difference?

Aleksei Valikov wrote:
> Hi.
>
> I'm trying to use SCD to attach my own customization elements to
classes and
> properties.
>
> This works:
>
> <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
> <jaxb:bindings
node="xs:complexType[@name='PurchaseOrderType']"-->
> <hj:table name="po"/>
> </jaxb:bindings>
> </jaxb:bindings>
>
>
> This does not:
>
> <jaxb:bindings scd="x-schema::">
> <jaxb:bindings scd="~PurchaseOrderType">
> <hj:table name="po"/>
> </jaxb:bindings>
> </jaxb:bindings>
>
>
> I get:
>
> [error] XJC while parsing schema(s)
> file:/.../src/main/resources/bindings.xjb[13,25]:
> org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of
> element 'hj:table'.
>
> Any ideas why and what can be done? I'd teally love to use the SCD.
>
> Bye.
> /lexi
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com