JAXB - ComplexType validation

Hi,
this is my first post here.
I use JWSPD 1.6 to validate my XML scheme and to bind it.
I have an application that build XML document in a certain manner, depending on a check on the binded schema.
My question is:
How can I use external API class for a type in the scheme?
For example, instead of:
<xsd:complexType name="MyComplexType">
   <xsd:sequence>
       <xsd:element name="Value" type="xsd:string">
       <xsd:element name="Id" type="xsd:string">
   </xsd:sequence>
</xsd:complexType> I would like to have:
<xsd:complexType name="MyComplexType">
   <xsd:sequence>
       <xsd:element name="Value" type="xsd:string">
       <xsd:element name="Id" type="extAPI.identifier">
   </xsd:sequence>
</xsd:complexType> I've tried to modify the xjc-generated classes, but I failed...
Thank you so much.

Invalid attribute value for 'type' in element 'element'. Recorded reason: UndeclaredPrefix
In attribute
type="extAPI.identifier"
a namespace is not declared for the extAPI prefix. To the schema root element add a namespace declaration for the extAPI prefix.
xmlns:extAPI="http://namespace"

Similar Messages

  • JAXB Unmarshall Validation Error Handling

    Hello,
    During unmarshalling, if say a required element is missing, a ValidationEvent is created and passed to the handleEvent(ValidationEvent e) method of a custom class implementing the ValidationEventHandler interface.
    From the ValidationEvent, one can get the ValidationEventLocator, which allows you to find out the column and row numbers of where the validation failed in the XML file.
    The problem is, this XML file that is being unmarshalled/marshalled is hidden from the user and not allowed to be accessed directly. I would like to tell the user where the validation failed by referencing nodes instead of column/line numbers.
    For example, if an element called 'foo' requires one child 'bar', and if 'bar' is discovered as missing during unmarshalling, the message that comes with the ValidationEvent will say:
    uncompleted content model. expecting: <bar>
    I don't see a way to find out exactly where in the entire XML file that 'bar' is supposed to occure. How do I find out that the 'bar' element is expected to be under 'foo' element?
    Using the Eclipse debugger, I can see that the parent 'foo' is referenced somewhere deep within the JAXB impl classes, but I don't see any public methods that will allow me to get it.
    Any ideas?
    Thanks,
    AJ

    Try 'ValidationEventLocation.getObject()', and see if you can narrow it down from there.
    I'm also looking for a better solution, since I have a case where a child element is violating it's pattern restrictions, but all I get is a reference to the parent, with no apparent indication as to which child is at fault.

  • JAXB 2 validation?

    Hi,
    Just right now I installed JAXB 2.0.
    Although the Java Web Services Tutorial for JWSDP v2.0 p33
    mentions a "Unmarshal Validate Example", this is
    not included in the samples dir anymore.
    Furthermore the Validator interface as well as
    the JAXBContext.setValidating() function is depricated.
    Calling this function anyway yields an exception ("not supported").
    How can I do validation in JAXB 2.0?
    Have fun,
    Klaus

    I ran into the same thing, and it seems they refactored the validation stuff into javax.xml.validation. Below is an example of a method I made to marshal an XJC-generated object to a DOMSource. Note that despite the method being for marshalling the validation is still on-demand, not on-marshal. Also note that the Validator class used is javax.xml.validation.Validator. The validate() method supports more advanced methods of retrieving the output but I am keeping it simple since I am new to JAXB and not trying to make my life complicated.
         public static DOMSource marshalToDOMSource(Object xmlObj, boolean doValidate)
              throws Exception{
              JAXBContext context = JAXBContext.newInstance("com.tmg.emkt.xml.bind");
              Marshaller marshaller = context.createMarshaller();
              SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
              Schema schema = sf.newSchema(new URL(schemaURL));
              String elementName = xmlObj.getClass().getName();
              elementName = elementName.substring(elementName.lastIndexOf(".")+1);
              marshaller.setProperty("jaxb.formatted.output", true);
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);
              DocumentBuilder db = dbf.newDocumentBuilder();
              Document doc = db.newDocument();
              marshaller.marshal(xmlObj,doc);
              DOMSource source = new DOMSource(doc);
              if (doValidate){
                   javax.xml.validation.Validator validator = schema.newValidator();
                   validator.validate(source);
              return source;
         }

  • JAXB Validation Error

    Hi,
    Iam using JAXB. I get an validation error. When i try to marshal an object to XML. The code is simple as shown below
    1. Container.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://agi.com"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://agi.com"
    elementFormDefault="qualified">
    <complexType name="ContainerType" abstract="true">
    <sequence>
    <choice>
    <element name="File" type="anyType" />
    <element name="Pen" type="anyType" />
    </choice>
    </sequence>
    </complexType>
    <element name="Container" type="tns:ContainerType" abstract="true" />
    </schema>
    2. Holder.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://agi.com"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://agi.com"
    elementFormDefault="qualified">
    <include schemaLocation="Container.xsd"></include>
    <complexType name="HolderType">
    <complexContent>
    <restriction base="tns:ContainerType">
    <sequence>
    <choice>
    <element name="File">
    <complexType>
    <sequence>
    <element name="FileName"
    type="string">
    </element>
    <element name="Capacity"
    type="integer">
    </element>
    </sequence>
    </complexType>
    </element>
    <element name="Pen">
    <complexType>
    <sequence>
    <element name="Make"
    type="string">
    </element>
    </sequence>
    </complexType>
    </element>
    </choice>
    </sequence>
    </restriction>
    </complexContent>
    </complexType>
    <element name="Holder" type="tns:HolderType"></element>
    </schema>
    Main.java
    package test.client;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.math.BigInteger;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;
    import javax.xml.bind.Unmarshaller;
    import javax.xml.bind.Validator;
    import test.vo.AnyType;
    import test.vo.Holder;
    import test.vo.ObjectFactory;
    import test.vo.HolderType.FileType;
    import test.vo.HolderType.PenType;
    import com.sun.xml.bind.StringInputStream;
    public class Main {
    public static void main(String s[]) throws Exception{
    JAXBContext ctx = JAXBContext.newInstance("test.vo" );
    ObjectFactory obj = new ObjectFactory();
    Holder input = obj.createHolder();
    FileType file = obj.createHolderTypeFileType();
    file.setCapacity( BigInteger.valueOf(35) );
    file.setFileName("Accounts");
    AnyType any = obj.createAnyType();
    List lst = any.getContent();
    lst.add(file);
    input.setFile(any);
    Marshaller marsh = ctx.createMarshaller();
    marsh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
    new Boolean(true));
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
    "http://agi.com");
    Validator validator = ctx.createValidator();
    validator.validate(input);
    StringWriter sw = new StringWriter();
    marsh.marshal(input, new PrintWriter(sw) );
    StringBuffer sb = sw.getBuffer();
    System.out.println(sb.toString() );
    This throws the following exception
    DefaultValidationEventHandler: [ERROR]: tag name "test.vo.AnyType" is not allowed. Possible tag names are: <test.vo.HolderType.FileType>
    Location: obj: test.vo.impl.HolderImpl@1cd8669
    Exception in thread "main" com.sun.xml.bind.serializer.AbortSerializationException: tag name "test.vo.AnyType" is not allowed. Possible tag names are: <test.vo.HolderType.FileType>
    at test.vo.impl.runtime.ValidationContext.reportEvent(ValidationContext.java:199)
    at test.vo.impl.runtime.ValidationContext.reportEvent(ValidationContext.java:166)
    at test.vo.impl.runtime.MSVValidator.childAsElementBody(MSVValidator.java:336)
    at test.vo.impl.runtime.MSVValidator.childAsBody(MSVValidator.java:292)
    at test.vo.impl.ContainerTypeImpl.serializeBody(ContainerTypeImpl.java:52)
    at test.vo.impl.HolderTypeImpl.serializeBody(HolderTypeImpl.java:30)
    at test.vo.impl.HolderImpl.serializeBody(HolderImpl.java:43)
    at test.vo.impl.runtime.MSVValidator._validate(MSVValidator.java:102)
    at test.vo.impl.runtime.MSVValidator.validate(MSVValidator.java:77)
    at test.vo.impl.runtime.ValidationContext.validate(ValidationContext.java:75)
    at test.vo.impl.runtime.ValidatorImpl.validate(ValidatorImpl.java:121)
    at test.vo.impl.runtime.ValidatorImpl.validate(ValidatorImpl.java:104)
    at test.client.Main.main(Main.java:63)
    However if i commentout the validation it works fine yeilding the
    following result
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Holder xsi:schemaLocation="http://agi.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://agi.com">
    <File>
    <FileName>Accounts</FileName>
    <Capacity>35</Capacity>
    </File>
    </Holder>
    Which look good conforming to the schema above
    It willbe helpful if someout could point out the mistake iam doing
    Please help
    Regards
    Agilan Palani

    I changed the code
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,"http://agi.com Holder.xsd");
    to
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,"http://agi.com E:/Agilan/Holder.xsd");
    But still the same error.
    I have validated the generated xml using XMLObjective. It says the generated xml is valid against the schema.
    I really dont know why the JAXB validation fails?
    Please help

  • Detailed error messages from jaxb validation

    Hi,
    I am developing an application that uses jaxb. When I validate an XML documenmt I am creating using the generated code, and validate the object the error message I get is not very detailed.
    I have a type that containes three elements. One of the elements is an enumeration. If i put an invalid value into that element in the type, and validate, the validation says :
    javax.xml.bind.ValidationException - with linked exception: [com.sun.xml.bind.serializer.AbortSerializationException: the value is not a member of the enumeration.]
    It does not mention the element name, or the possible values of the enumration or the value set.
    If I validate in oxygen XML or another tool it tells me the name of the element and possible values.
    How do I do this in my code?
    I have already made my own validator from a copy of DefaultValidationHandler and run that, but in that code I only get a handle to the top level complexType.
    How do I get the information about which child element relates to the error message? Or is there another strategy to get this info ?
    Thanks
    Paul.

    I am one of the many getting this error. In my case I am trying to connect to my wife. She is on a brand new intel macbook. I am on a iMac G5. My error message is below and doesn't seem to have the same issues referenced by the earlier user. Thoughts?
    Video Conference Error Report:
    24.600844 @:0 type=4 (00000000/2)
    [VCSIP_INVITEERROR]
    [19]
    24.600695 @SIP/SIP.c:2437 type=4 (900A0015/2)
    [SIPConnectIPPort failed]
    Video Conference Support Report:
    24.101248 @SIP/Transport.c:1218 type=1 (00000000/0)
    [INVITE sip:[email protected] SIP/2.0
    Via: SIP/2.0/UDP 192.168.15.100;branch=z9hG4bK26fc92013a67f90a
    Max-Forwards: 70
    To: "u0" <sip:[email protected]>
    From: "[email protected]" <sip:[email protected]>;tag=832276631
    Call-ID: 39f2e40a-16bf-11db-8b4f-d21f408913c4@lip
    CSeq: 1 INVITE
    Contact: <sip:[email protected]>;isfocus
    User-Agent: Viceroy 1.2
    Content-Type: application/sdp
    Content-Length: 532
    v=0
    o=graeme_hepworth 0 0 IN IP4 192.168.15.100
    s=[email protected]
    c=IN IP4 192.168.15.100
    b=AS:2147483647
    t=0 0
    a=hwi:784:1:2000
    a=bandwidthDetection:YES
    a=iChatEncryption:YES
    m=audio 16386 RTP/AVP 12 3 0
    a=rtcp:16387
    a=rtpmap:3 GSM/8000
    a=rtpmap:0 PCMU/8000
    a=rtpID:-1207316380
    m=video 16384 RTP/AVP 126 34
    a=rtcp:16385
    a=rtpmap:126 X-H264
    a=fmtp:34 imagesize 1 rules 30:352:288
    a=framerate:30
    a=RTCP:AUDIO 16387 VIDEO 16385
    a=pogo
    a=fmtp:126 imagesize 0 rules 30:320:240:320:240
    a=rtpID:1258096851
    ]

  • Problem validating xml file - jaxb

    hi people, I'm working with jaxb to generate Java source classes from the .xsd schemas that I have. I work with 17 schemas that, a priori, I can't modify. In those schemas there are a lot of types and structures that I can use when creating an .xml file. I've read other threads with the problem of namespaces but as a solution they provide a modification on the schemas. The generation of java source is ok, I've done custoization classes and no problem, but when I try to unmarshal an input xml file I get an error of validation:
    DefaultValidationEventHandler: [ERROR]: Probably namespace URI of tag "XFFile" is wrong (correct one is "http://ww........
    A possible xml file is :
    <?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE XFFile><XFFile xmlns:rp210Elements="http://www.smpte-ra.org/schemes/434/200X/multiplex/S377M/2004" xmlns:s377mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S377M/2004" xmlns:s377mMux="http://www.smpte-ra.org/schemes/434/200X/multiplex/S377M/2004" xmlns:s377mTypes="http://www.smpte-ra.org/schemes/434/200X/types/S377M/2004" xmlns:s380mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S380M/2004" xmlns:s381mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S381M/200X" xmlns:s382mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S382M/200X" xmlns:s385mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S385M/2004" xmlns:s422mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S422M/200X" xmlns:s422mTypes="http://www.smpte-ra.org/schemes/434/200X/types/S422M/200X" xmlns:s423mGroups="http://www.smpte-ra.org/schemes/434/200X/groups/S423M/200X">
         <s380mGroups:ClipFramework rp210Elements:InstanceID="a6.67.7a.47.19.2f.4b.10.8f.ee.1e.59.6d.4c.f1.70" rp210Elements:LinkedGenerationID="0e.10.a8.9c.96.1c.4c.11.b1.fb.0a.a9.40.22.a4.e2">
              <rp210Elements:ClipCreationDateTime>
                   <rp210Elements:Year>2006</rp210Elements:Year>
                   <rp210Elements:Month>4</rp210Elements:Month>
                   <rp210Elements:Day>18</rp210Elements:Day>
                   <rp210Elements:Hour>12</rp210Elements:Hour>
                   <rp210Elements:Minute>0</rp210Elements:Minute>
                   <rp210Elements:Second>0</rp210Elements:Second>
                   <rp210Elements:mSec4>0</rp210Elements:mSec4></rp210Elements:ClipCreationDateTime>
              <rp210Elements:FrameworkExtendedTextLanguageCode>fr</rp210Elements:FrameworkExtendedTextLanguageCode>
         </s380mGroups:ClipFramework>
    </XFFile>
    I think it's ok because someone has provided it to my company but I can't validate it because it takes elements from many schemas (am I wrong and I can?)
    i can't post the schemas because of the copyrights (damn it). I'm not asking for a solution but if someone has an idea or has had a similar problema.. I'll appreciate all comments, thanks
    Jordi
    Message was edited by:
    WuWei

    In the schema root element xs:schema add namespace declaration.
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    In the XML document root element add xmlns:xsi and xsi:noNamespaceSchemaLocation attributes.
    <root_element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://c:/testing.xsd">

  • Force JAXB  to use custom base class on a per complexType basis?

    I know I can <superClass="Blah"> in <globalBindings> to make all classes use "Blah" as a super class. Is there a way to get a complexType to use its own user defined base class?
    I'd like the JAXB compiler to generate the following classes for the schema below:
    What I'd like JAXB compiler to create:
    class A extends MyUserDefinedAbstractA{}...
    class B extends MyUserDefinedAbstractB{};For my own base classes:
    abstract class MyUserDefinedAbstractA {}
    abstract class MyUserDefinedAbstractB {}Based on the following schema:
    <complexType name="A"> .... </complexType>
    <complexType name="B"> .... </complexType>What is the alternative if I can't do the above? I'd like the generated classes to more than just hold data. I'd like them to have methods that can operate on the data as well.
    Regards,
    Monty
    Edited by: CuriousJorj on Jul 9, 2008 6:33 AM
    Edited by: CuriousJorj on Jul 9, 2008 6:35 AM

    There are some Safari extensions that can block JavaScript by domain, but you'll have to search for them.

  • Urgent Help on JAXB Validation - Please Help

    I have an application that needs validation before marshalling a content tree. If the tree is not valid, I need to marshall the tree and look at the problem in the XML file itself.
    If it's a valid XML file, then continue as usual...
    These is the pseudo code.. But don't know if I can implement it with JAXB or not....And how to implement it..
    populate XML tree
    check if the tree is valid or not
    if it is valid continue processing
    if not valid, marshall the tree into an XML file and analyze the
    problem
    Any input is welcome...
    Thanks in advance..

    svenkatesh s, thanks for your reply. In addition to your suggestion,
    I found this method:
    public class ValidationHelper implements ValidationEventHandler {
    public boolean handleEvent(ValidationEvent arg0) {
         System.out.println("The message is: " + arg0.getMessage());
         System.out.println("The severity is: " + arg0.getSeverity());
         ValidationEventLocator locator = arg0.getLocator();
         System.out.println("The column number: " + locator.getColumnNumber());
         System.out.println("The line number: " + locator.getLineNumber());
              Node nd = locator.getNode();
              log.write(Logger.LOG_INFO, "The node: " + nd);
              String st = nd.getNodeName();
              log.write(Logger.LOG_INFO, "Node Name " + st);
              String stt = nd.getNodeValue();
              log.write(Logger.LOG_INFO, "Node Value: " + stt);
              return true;
    I noticed that Node is null, but it might be a test data problem...

  • JAXB - validation problem with regexp bound int type

    Hello everyone,
    I have a simpleType defined in my schema as follows:
    <xs:simpleType name="BasketRetentionType">
    <xs:restriction base="xs:int">
    <xs:totalDigits value="10"/>
    <xs:pattern value="(0|[1-9][0-9]*)"/>
    </xs:restriction>
    </xs:simpleType>
    '020' and '+20' values are not allowed (as I need it to be), but I've got them validated by JAXB.
    I wonder if there's anyone who can confirm this or shall I add any java code I may have ignored.
    I'm working with :
    - OS : Microsoft Windows NT v4.0 Serv.Pack6
    - java : j2sdk1.4.1_05
    - jaxb : jwsdp-1.3
    Thanks
    L. Chiartano

    Try this pattern: +\\d*|\\d*
    Also take a look at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
    I don't know if it's \\d or \d, trail and error.
    bye ki

  • JAXB 2.0 validation when marshalling

    Hi,
    I'm using JAXB to marshall and unmarshall files. The issue i'm trying to address is that when a file is being marshalled - if a value is mandatory in the schema and if the user provides null value or something then shoulding this be a validation error? I dont get any notification even if I have attached a validationhandler to my marshaller and the file is created with that particular value blank.... so anyone has any idea of how we can validate the documents created by JAXB that they're valid.
    thanks
    SA

    Ok i figured out one way of doing this by using some classes from JAXP...
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema s = null;
    try{
        s = sf.newSchema(new File("Sources/schema/test.xsd"));                    
    }catch(Exception e){
        System.err.println("Exception e: " + e.getMessage());
    marshaller.setSchema(s);
    //MyValidationHandler class implements the ValidationEventHandler interface
    MyValidationHandler gv = new MyValidationHandler();
    marshaller.setEventHandler(gv);If anyone has something to add let me know!!

  • JAXB XML Unmarshalling validation problem

    Hello,
    I'm using toplink JAXB to map XML document to an object hierarchy. The set of objects was built using Toplink workbench from the corresponding XSD file. The XSD file is specified in <toplink:resource> element using an absolute path. If I use unmarshaller validation (Unmarshaller u = jc.createUnmarshaller(); u.setValidating(true)) it works fine in embedded oc4j, but fails withan UnmarshalException "An internal error condition occurred" for Line N 1.
    It looks like the cause of the exception is that toplink cannot find the XSD file. I've tried to put the XSD file into META-INF and into classes directly, and specify the relative path, but it has failed event locally in the embedded oc4j.
    Everything works if I do not turn the validation on.
    Has anybody gotten the same issue? What could be a solution if we have to perform the validation?
    Thanks
    Kate

    Hello Kate,
    One possible work around would be use the TopLink OXM specific APIs for this unmarshal. For the most part they mirror the JAXB APIs so there usage is pretty straight forward.
    XMLContext xmlContext = new XMLContext(YOUR_JAXB_CONTEXT_PATH);
    xmlUnmarshaller = xmlContext.createUnmarshaller();One API that we offer that is not part of the standard JAXB Unmarshaller is the ability to specify an EntityResolver. This class allows you to override where the XML Schema is loaded from.
    EntityResolver entityResolver = new YourEntityResolver();
    xmlUmarshaller.setEntityResolver(entityResolver);YourEntityResolver must implement org.xml.sax.EntityResolver. There is one method on this interface that returns an InputSource representing the XML Schema. You can implement this method to load the Schema from a ClassLoader.
    -Blaise

  • JAXB Validation

    Using JAXB I have generated and compiled classes for my schema and everything appears ok.
    I can create new objects using the ObjectFactory and I am able to validate those objects.
    If an object is invalid I know how to inspect the resultant ValidationEvent and determine why the error occurred.
    However, although I am able to determine the cause of a validation failure, how can I determine - and this is the important bit for me - without prior knowledge of the schema, how to resolve this failure.
    For example:
    My schema allows me to create Apple objects. Each apple must have a type and that type must be either 'one ' or 'two'
    Therefore:
    valid - <apple><type>one<type></apple>
    invalid - <apple><type>three<type></apple>
    invalid:- <apple></apple>
    The following bit of code will create a valid apple object:
    ObjectFactory objFactory = new ObjectFactory();
    AppleImpl apple = (AppleImpl)objFactory.createApple();
    apple.setType("one);
    However, without calling setType("one") my apple object will be invalid.
    Examining that ValidationEvent returned from validating the object I can determine what is wrong with the object.
    ValidationEvent event;
    event.getNode() -> null
    event.getLocator().getSeverity() -> 1
    event.getLocator().getColumnNumber() -> 1
    event.getLocator().getLineNumber() -> -1
    event.getLocator().getOffset( ) -> -1
    event.getLocator().getURL( ) -> null
    event.getLocator().getObject( ) -> Apple@d1c65d
    event.getLocator().toString( ) -> So now I know the problem is with the type field.
    However, without prior knowledge of the schema and without knowing the type field must be set to 'one' or 'two' then how can I determine this? What methods are available in JAXB to determine what values I can set type to?
    Or is this beyond the scope of JAXB?
    (also posted in Java Technologies for Web Services -wasn't sure of best place for it)

    Many thanks for your response. However, if you have any code snippets/examples relating I go from JAXB to look at DOM validation that 'd be useful. In fact, anything at all as to where I should start looking.
    Hi ,
    Did u find any solution,please let me know.

  • Howto? XMLSchema validation on abstract/substitutionGroup and complexType

    Hi, I'm following the examples on [http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96621/adx06scj.htm|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96621/adx06scj.htm] .
    A little change and it worked for me. I wanted to try out a schema construction from the XBRL world, but it seems to fail somewhere on the abstract/substitionGroup contruction when combined with custom types.
    I keep getting:
    catalogue.xml&lt;Line 11, Column 36&gt;: XML-24534: (Error) Element 'testitem' not expected.
    catalogue.xml&lt;Line 12, Column 15&gt;: XML-24534: (Error) Element 'Book' not expected.
    catalogue.xml&lt;Line 19, Column 15&gt;: XML-24534: (Error) Element 'Book' not expected.
    Removing the attribute from the XMLSchema and setting type=String instead of stringItemType does let xmlparserv2 validate the file.
    An editor like EditiX does validate the XML file against the Schema.
    xmlparserv2.jar from .xdk_version_10.2.0.2.0_production
    How do I solve this?
    The file, notice the testitem:
    &lt;?xml version="1.0"?&gt;
    &lt;Catalogue xmlns="http://www.publishing.org/namespaces/Catalogue"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=
    "http://www.publishing.org/namespaces/Catalogue
    cat.xsd"&gt;
    &lt;Magazine&gt;
    &lt;Title&gt;Natural Health&lt;/Title&gt;
    &lt;Date&gt;1999&lt;/Date&gt;
    &lt;/Magazine&gt;
    {color:#ff0000}&lt;testitem contextRef="bla"&gt;Natural Health&lt;/testitem&gt;{color}
    &lt;Book&gt;
    &lt;Title&gt;Illusions The Adventures of a Reluctant Messiah&lt;/Title&gt;
    &lt;Author&gt;Richard Bach&lt;/Author&gt;
    &lt;Date&gt;1977&lt;/Date&gt;
    &lt;ISBN&gt;0-440-34319-4&lt;/ISBN&gt;
    &lt;Publisher&gt;Dell Publishing Co.&lt;/Publisher&gt;
    &lt;/Book&gt;
    &lt;Book&gt;
    &lt;Title&gt;The First and Last Freedom&lt;/Title&gt;
    &lt;Author&gt;J. Krishnamurti&lt;/Author&gt;
    &lt;Date&gt;1954&lt;/Date&gt;
    &lt;ISBN&gt;0-06-064831-7&lt;/ISBN&gt;
    &lt;Publisher&gt;Harper &amp; Row&lt;/Publisher&gt;
    &lt;/Book&gt;
    &lt;/Catalogue&gt;
    The XMLSchema, notice the type=anyType, stringItemType and element testitem:
    &lt;?xml version="1.0"?&gt;
    &lt;schema {color:#00ff00}xmlns="http://www.w3.org/2001/XMLSchema"{color}
    targetNamespace="http://www.publishing.org/namespaces/Catalogue"
    elementFormDefault="qualified"
    xmlns:xbrli="http://www.publishing.org/namespaces/Catalogue"
    xmlns:cat="http://www.publishing.org/namespaces/Catalogue"&gt;
    &lt;complexType name="PublicationType"&gt;
    &lt;sequence&gt;
    &lt;element name="Title" type="string" minOccurs="1"
    maxOccurs="unbounded"/&gt;
    &lt;element name="Author" type="string" minOccurs="1"
    maxOccurs="unbounded"/&gt;
    &lt;element name="Date" type="string" minOccurs="1" maxOccurs="1"/&gt;
    &lt;/sequence&gt;
    &lt;/complexType&gt;
    &lt;element name="item"{color:#ff0000} type="anyType"{color} abstract="true"&gt;
    &lt;annotation&gt;
    &lt;documentation&gt;
    Abstract item element used as head of item substitution group
    &lt;/documentation&gt;
    &lt;/annotation&gt;
    &lt;/element&gt;
    {color:#ff0000}&lt;complexType name="stringItemType" final="extension"&gt;
    &lt;simpleContent&gt;
    &lt;extension base="string"&gt;
    &lt;attribute name="contextRef" type="string" use="required" /&gt;
    &lt;/extension&gt;
    &lt;/simpleContent&gt;
    &lt;/complexType&gt;
    &lt;element
    name="testitem"
    type="cat:stringItemType"
    substitutionGroup="xbrli:item"
    nillable="true"
    xbrli:periodType="duration"/&gt;{color}
    &lt;element name="Book" substitutionGroup="cat:item"&gt;
    &lt;complexType&gt;
    &lt;complexContent&gt;
    &lt;extension base="cat:PublicationType"&gt;
    &lt;sequence&gt;
    &lt;element name="ISBN" type="string" minOccurs="1"
    maxOccurs="1"/&gt;
    &lt;element name="Publisher" type="string" minOccurs="1"
    maxOccurs="1"/&gt;
    &lt;/sequence&gt;
    &lt;/extension&gt;
    &lt;/complexContent&gt;
    &lt;/complexType&gt;
    &lt;/element&gt;
    &lt;element name="Magazine" substitutionGroup="cat:item"&gt;
    &lt;complexType&gt;
    &lt;complexContent&gt;
    &lt;restriction base="cat:PublicationType"&gt;
    &lt;sequence&gt;
    &lt;element name="Title" type="string" minOccurs="1"
    maxOccurs="unbounded"/&gt;
    &lt;element name="Author" type="string" minOccurs="0"
    maxOccurs="0"/&gt;
    &lt;element name="Date" type="string" minOccurs="1" maxOccurs="1"/&gt;
    &lt;/sequence&gt;
    &lt;/restriction&gt;
    &lt;/complexContent&gt;
    &lt;/complexType&gt;
    &lt;/element&gt;
    &lt;element name="Catalogue"&gt;
    &lt;complexType&gt;
    &lt;sequence&gt;
    &lt;element ref="cat:item" minOccurs="0"
    maxOccurs="unbounded"/&gt;
    &lt;/sequence&gt;
    &lt;/complexType&gt;
    &lt;/element&gt;
    &lt;/schema&gt;
    Edited by: Luuk on Sep 17, 2008 9:46 AM

    Thanks you for the information!
    Shape of the document conforms to the schema. Data types are correct. Shape means hierarchy of elements and element names, correct data types in the sense of build in SQL data types to store the information in the tables?
    On the other side, xsd:restriction, xsd:unique, xsd:key/keyref,... is not checked?
    OK. Now I can know what happens when no validation constraint is defined.
    It is a good idea to give the developer the choise ;-)
    but I feel uncomfortable when I can enter non-valid XML data. In my applications, I would like to have the validation turned on!
    Please, lets go back to my first posting in this thread:
    When inserting an XML document into a table with XML Schema validation I get an ORA-03113!
    What does wrong?

  • JAXB marshalling complexType elements

    Does anyone know why JAXB always marshalls complexType elements with a seperate start and end tag, even if the element has no content?
    i.e.
    Given the schema element declaration:
    <xs:element name="foo" type="fooType"/>
    <xs:complexType name="fooType">
    <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    Why do I get:
    <foo value="bar"></foo>
    Instead of:
    <foo value="bar"/>
    Is their a setting / property to control this behaviour?
    If not then I certainly think there should be because this will bloat the 5Mb XML files I am currently dealing with by quite a lot.
    Cheers,
    Simon

    I have exactly the same trouble here. Did you find a solution? If so, please contact me. I am so afraid of increase the amount space used to store all XML files.
    Thanks in advance
    Julio Garc�a
    [email protected]

  • JAXB Validation without a Schema

    Part of the benefit of JAXB is that a schema is not required; annotating Java classes alone allows for XML serialization/deserialization. With the deprecation of the Unmarshaller.setValidating() in favor of the unmarshaller.setSchema() method, however, it seems that validation is only available when an XSD is present. Is there another way to validate XML during unmarshalling without a physical schema file?

    Unmarshaller#setValidating(boolean) is deprecated as of 2.0 [1].
    This method throws an UnsupportedOperationException in the UnmarshallerImpl class within sun's v2 jaxb implementation.
    [1] https://jaxb.dev.java.net/nonav/jaxb20-pfd/api/javax/xml/bind/Unmarshaller.html#setValidating(boolean)

Maybe you are looking for

  • Slideshow: show image description in caption?

    Hi All, is there a way to include an image-description trough Meta-Data when using the Slideshow-Feature and showing "full" captions? I tried entering all sorts of descriptions through File-Info but nothing of that appears in the caption. Did I miss

  • Sharp bright light at the centre

    Sharp bright light appears on my Lacie 17" CRT display intermittently which disppears and returns to normal after power off for some few minutes. The monitor is attached to my G4 machine with OS 9.2.2 and OS X 10.2.8 on it. Thanks for the help power

  • I am looking at an MP3 player with the capability to download audio-books. Is the Nano the one for me?

    I need a new mp3 player & have never had an Apple product. A must have "accessory" is to download e books. Is this the product for me?

  • Error starting Weblogic workshop 8.1

    Hi, I have trouble starting Weblogic workshop 8.1. I tried uninstalling it and reinstalling it, still the error persists. So I cannot run workshop on my desktop at all. I have included the error at the end. Any suggestions? Please let me know. Regard

  • Integration of Demantra 7.3 with JDE 9.0

    Hi All, Plz can some one guide me to integrate standalone Demantra 7.3 with JDE 9.0 and integration of VCP 12.1 with JDE 9.0. Plz let me know what is the pre requisites for this Regards Sajid