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<Line 11, Column 36>: XML-24534: (Error) Element 'testitem' not expected.
catalogue.xml<Line 12, Column 15>: XML-24534: (Error) Element 'Book' not expected.
catalogue.xml<Line 19, Column 15>: 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:
<?xml version="1.0"?>
<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">
<Magazine>
<Title>Natural Health</Title>
<Date>1999</Date>
</Magazine>
{color:#ff0000}<testitem contextRef="bla">Natural Health</testitem>{color}
<Book>
<Title>Illusions The Adventures of a Reluctant Messiah</Title>
<Author>Richard Bach</Author>
<Date>1977</Date>
<ISBN>0-440-34319-4</ISBN>
<Publisher>Dell Publishing Co.</Publisher>
</Book>
<Book>
<Title>The First and Last Freedom</Title>
<Author>J. Krishnamurti</Author>
<Date>1954</Date>
<ISBN>0-06-064831-7</ISBN>
<Publisher>Harper & Row</Publisher>
</Book>
</Catalogue>
The XMLSchema, notice the type=anyType, stringItemType and element testitem:
<?xml version="1.0"?>
<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">
<complexType name="PublicationType">
<sequence>
<element name="Title" type="string" minOccurs="1"
maxOccurs="unbounded"/>
<element name="Author" type="string" minOccurs="1"
maxOccurs="unbounded"/>
<element name="Date" type="string" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
<element name="item"{color:#ff0000} type="anyType"{color} abstract="true">
<annotation>
<documentation>
Abstract item element used as head of item substitution group
</documentation>
</annotation>
</element>
{color:#ff0000}<complexType name="stringItemType" final="extension">
<simpleContent>
<extension base="string">
<attribute name="contextRef" type="string" use="required" />
</extension>
</simpleContent>
</complexType>
<element
name="testitem"
type="cat:stringItemType"
substitutionGroup="xbrli:item"
nillable="true"
xbrli:periodType="duration"/>{color}
<element name="Book" substitutionGroup="cat:item">
<complexType>
<complexContent>
<extension base="cat:PublicationType">
<sequence>
<element name="ISBN" type="string" minOccurs="1"
maxOccurs="1"/>
<element name="Publisher" type="string" minOccurs="1"
maxOccurs="1"/>
</sequence>
</extension>
</complexContent>
</complexType>
</element>
<element name="Magazine" substitutionGroup="cat:item">
<complexType>
<complexContent>
<restriction base="cat:PublicationType">
<sequence>
<element name="Title" type="string" minOccurs="1"
maxOccurs="unbounded"/>
<element name="Author" type="string" minOccurs="0"
maxOccurs="0"/>
<element name="Date" type="string" minOccurs="1" maxOccurs="1"/>
</sequence>
</restriction>
</complexContent>
</complexType>
</element>
<element name="Catalogue">
<complexType>
<sequence>
<element ref="cat:item" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>
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?

Similar Messages

  • Question about abstract classes and instances

    I have just read about abstract classes and have learned that they cannot be instantiated.
    I am doing some exercises and have done a class named "Person" and an abstract class named "Animal".
    I want to create a method in "Person" that makes it possible to set more animals to Person objects.
    So I wrote this method in class Person and compiled it and did not get any errors, but will this work later when I run the main-method?
    public void addAnimal(Animal newAnimal)
         animal.add(newAnimal);
    }Is newAnimal not an instance?

    Roxxor wrote:
    Ok, but why is it necessary with constructors in abstract classes if we don�t use them (because what I have understand, constructors are used to create objects)?Constructors don't create objects. The new operator creates objects. An object's c'tor is invoked after the object has already been created. The c'tors job is to initialize the newly-created object to a valid state. Whenever a child object is created, the parent's c'tor is run before the child's c'tor, so that by the time we're inside the child's c'tor, setting up the child's state, we know that the parent (or rather the "parent part" of the object we're initializing) is in a valid state.
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • JAXB: Abstract Types and Substitution Group Errors

    I am using several schemas as defined below:
    Schema 1 defines an abstract type
    Schema 2 extends abstract type
    Schema 3 makes reference to abstract type in 1 and is using substitution groups on the abstarct type
    The error only occurs when the element is Abstract and what extends
    the abstract element specify a substitution group (which I believe is
    correct according to
    http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#abstract). I can't
    remove the substitution group because declaring the element as abstract
    requires this. Is there a way to fix this?
    code that generates error:
    When attempting to do a JAXBContext jaxbContext = JAXBContext.newInstance(Schema3.class) I get the following error
    Exception in thread "main" com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    There's no ObjectFactory with an @XmlElementDecl for the element {[http://test.com/FeatureBase.xsd|http://seams.csp.com/FeatureBase.xsd]}FeatureBase.
         this problem is related to the following location:
              at com.test.blah
         at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:448)
         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:297)
         at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
         at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:214)
         at javax.xml.bind.ContextFinder.find(ContextFinder.java:375)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)

    Hi all,
    This seems to be a bug unless someone of you have a solution.
    Also I ma new to xml/xsd world, so could someone please give the differences between xsi:type vs substitution groups with both element and complex type being abstract. Can this scenario be accomplished by usuage of choice groups.
    Also can anyone suggest any other good xml forums.
    Please let me know.
    Thanks in advance.

  • Generics w/ abstract classes and contructors

    Here's my setup:
    abstract class AC
    AC(){};
    AC(String S){};
    abstract boolean IsValid();
    class RC extends AC
    public RC(){.........................};
    public RC(String S){...........................};
    public boolean IsValid(){...........................};
    class ACContainer<T extends AC>
    public void ErrorFunc(String Str)
    T tobj = new T(Str);
    My problem is that it doesn't let ErrorFunc create a "new T(Str)" when I create an ACContainer<RC> RCContObj with a call to ErrorFunc.
    Why not?
    I get "unexpected type"
    Edited by: mikeatrxs on Apr 24, 2008 1:10 PM
    Edited by: mikeatrxs on Apr 24, 2008 1:11 PM

    Reac a Generics tutorial. Type parameters are erased at compile time. There is no way it knows at runtime what class you want to create an instance of, unless you additionally pass in a Class object that tells it what class it is. It makes more sense if you ask, what happens when you "erase" the generic type parameters? Any valid Generics program should be able to erase to a valid non-Generics program and vice versa. But how are you going to erase the "new T(Str)"? How would you do this without Generics?

  • What is the diff b/w Abstract class and an interface ?

    Hey
    I am always confused as with this issue : diff b/w Abstract class and an interface ?
    Which is more powerful in what situation.
    Regards
    Vinay

    Hi, Don't worry I am teach you
    Abstract class and Interface
    An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.
    Edited by SASIKUMARA
    SIT INNOVATIONS- Chennai
    Message was edited by:
    sasikumara
    Message was edited by:
    sasikumara

  • Have an issue regarding library books. My ereader is validated with Kobo account and Adobe Digital Editions account, but I get an error: 'this document is protected bij DRM and isn't available with your Adobe ID'.

    Have an issue regarding library books. My ereader is validated with Kobo account and Adobe Digital Editions account, but I get an error: 'this document is protected bij DRM and isn't available with your Adobe ID'.

    same problem for me. I am using abe edition 3 as I don't think 4 can be used with kobo. Book has been downloaded to kobo but it can't be read as it is not authorised.Help please

  • Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset pref

    Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset preferences and still have problem. Slow to open and in force quit "Photoshop not responding" At this point should I uninstall and start over.

    What are the performance Preferences?

  • Difference between abstract interface and normal interface

    Hello Friends,
    What is the Difference between abstract interface and normal interface?....

    What is the Difference between abstract interface and
    normal interface?....The difference is that you didn't follow convention in the first case. All interfaces are implicitly abstract so you don't have to declare them as such.

  • Difference between abstract class and the normal class

    Hi...........
    can anyone tell me use of abstract class instead of normal class
    The main doubt for me is...
    1.why we are defining the abstract method in a abstract class and then implementing that in to the normal class.instead of that we can straight way create and implement the method in normal class right...../

    Class vs. interface
    Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme. I use interfaces when I see that something in my design will change frequently.
    For example, the Strategy pattern lets you swap new algorithms and processes into your program without altering the objects that use them. A media player might know how to play CDs, MP3s, and wav files. Of course, you don't want to hardcode those playback algorithms into the player; that will make it difficult to add a new format like AVI. Furthermore, your code will be littered with useless case statements. And to add insult to injury, you will need to update those case statements each time you add a new algorithm. All in all, this is not a very object-oriented way to program.
    With the Strategy pattern, you can simply encapsulate the algorithm behind an object. If you do that, you can provide new media plug-ins at any time. Let's call the plug-in class MediaStrategy. That object would have one method: playStream(Stream s). So to add a new algorithm, we simply extend our algorithm class. Now, when the program encounters the new media type, it simply delegates the playing of the stream to our media strategy. Of course, you'll need some plumbing to properly instantiate the algorithm strategies you will need.
    This is an excellent place to use an interface. We've used the Strategy pattern, which clearly indicates a place in the design that will change. Thus, you should define the strategy as an interface. You should generally favor interfaces over inheritance when you want an object to have a certain type; in this case, MediaStrategy. Relying on inheritance for type identity is dangerous; it locks you into a particular inheritance hierarchy. Java doesn't allow multiple inheritance, so you can't extend something that gives you a useful implementation or more type identity.
    Interface vs. abstract class
    Choosing interfaces and abstract classes is not an either/or proposition. If you need to change your design, make it an interface. However, you may have abstract classes that provide some default behavior. Abstract classes are excellent candidates inside of application frameworks.
    Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class may provide default services such as event and message handling. Those services allow your application to plug in to your application framework. However, there is some application-specific functionality that only your application can perform. Such functionality might include startup and shutdown tasks, which are often application-dependent. So instead of trying to define that behavior itself, the abstract base class can declare abstract shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn't know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, Java calls the method defined by the child class.

  • Validation for Profit Center and Trading Partner

    Hi Gurus,
    Please help me in creating validation for Profit Center and Trading Partner.
    I want system to give an error if we use Trading Partner related to particular profit centers.
    Please revert asap.
    Thank You

    Hello,
    Please use T.code OB28 and select the call up point 2.
    Than go to Prerequisite in expert mode and say
    Prerequisite  :           BSEG-VBUND <> ' '
      Check:               BSEG-PRCTR = ' '
      Error Message.: xyz
    I have created Validation understanding if someone gives Trading Partner and also Profit center while posting a doc than it will generate an error message.
    however if you have some diff req please change it accordingly/ take Abapers helps if not very clear.
    I hope this helps
    Regards
    Shireesh

  • When we will go for an abstract class and when we will go for an interface?

    it's always some what confusing to choose an abstract class and an interface,can anybody post a suitable answer for this.

    jwenting wrote:
    with experience and the insight it brings, you will know which to use when.
    Without it, it can't be explained.
    More often than not there's no X OR Y anyway.It's fortunate that there are posters here who possess the insight and experience necessary to explain this. The principal differences between an abstract class and an interface are,
    1. An abstract class can carry implementation, whereas an interface cannot.
    2. An abstract class is singly inherited, wheras an interface is multiply inherited.
    So use an abstract class when the implementation it can carry outweights the fact that it cannot be multiply inherited That's the gist of it.
    The inheritance relationship where this happens is when the supertype is a general concept of which all potential subtypes are special cases. This is called a specialization (or sometimes a generalization) relationship. For example Apple and Banana are Fruit. Or Car and Bike are Vechicle. The Fruit and Vechicle supertypes are general concepts of which their subtypes are special cases. In this case make Fruit and Vechicle abstract classes because the subtypes will benefit from a shared implementation.
    If you don't have a clearcut specialization/generalization relationship make the supertype an interface. An example could be the Comparable supertype. The potential subtypes aren't supposed to be specializations of the Comparable concept, they're suppose to become Comparable (and make this property an integral part of their being). This is not a specialization/generalization relationship. Instead the supertype is intended to add character to the subtypes. The subtypes are unlikely to benefit from an inherited implementation. So make Comparable an interface.

  • About abstract interface and it's method

    Hi !!
    HttpSession session = request.getSession();
    getSession() is the Method of HttpSession and it is the abstract interface..
    right ??
    so how can we call the abstract method and ..
    here... request is the object of HttpServletRequest which is abstract interface so how can we make an Object of this abstract interface...
    I m very confused Please solve my Querry ASAP

    As far as I can tell, these three threads are all the same person asking the same question.
    http://forum.java.sun.com/thread.jspa?threadID=5188609
    http://forum.java.sun.com/thread.jspa?threadID=5188638
    http://forum.java.sun.com/thread.jspa?threadID=5188603
    How obnoxious.

  • Abstract method and class

    I'm a beginner in Java and just learn about abstract method and class.
    However, i am wondering what is the point of using abstract method/class?
    Because when I delete the abstract method and change the class name to public class XXXX( changed from "abstract class XXXX), my program still runs well, nothing goes different.
    Is it because I haven't encountered any situation that abstract method is necessary or ?
    Thanks!

    Yes - you probably haven't encountered a situation where you need an abstract.
    Abstract classes are not designed to do anything on their own. They are designed to provide a template for other classes to extend by inheritance. What you have build sounds like a concrete class - one which you are creating instances of. Abstract classes are not designed to be ever instantiated in their pure form - they act like a partial building block, which you will complete in a class which extends the abstract.
    An example might be a button class, which provides some core functionality (like rollover, rollout etc) but has an empty action method which has to be overwritten by a relevant subclass like 'StartButton'. In general, abstract classes may not be the right answer, and many people would argue that it is better to use an interface, which can be implemented instead of extended, meaning that you can ADD instead of REPLACING.
    Not sure if that helps.. there are whole chapters in books on this kind of thing, so it's hard to explain in a couple of paragraphs. Do some google searches to find out more about how they work.

  • BADI or User Exit validation of operations tab and displaying an error mess

    Hello,
    Could you please let me know the BADI or User Exit validation of operations tab and displaying an error message in iw32
    Thanks,
    Suresh Mgl

    Hi ..
    I tried that user-exit...but i need to block the changes for purchase requisition which is in released stutus..
    .i hope i need to do implicite enchancement spot.....could you please help me to do that..
    Thanks,
    Suresh Mgl

  • Why does this abstract class and method work without implement it?

    hi,
    I have seen many times that in some examples that there are objects made from abstract classes directly. However, in all books, manual and tutorials that I've read explain that we MUST implement those methods in a subclass.
    An example of what I'm saying is the example code here . In a few words that example makes Channels (java.nio.channel) and does operations with them. My problem is in the class to make this channels, because they used the ServerSockeChannel class and socket() method directly despite they are abstracts.
       // Create a new channel: if port == 0, FileChannel on /dev/tty, else
       // a SocketChannel from the first accept on the given port number
    private static ByteChannel newChannel (int netPort)
          throws Exception
          if (netPort == 0) {
             FileInputStream fis = new FileInputStream ("/dev/tty");
             return (fis.getChannel());
          } else {
    //CONFLICT LINES
             ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
             ssc.socket().bind (new InetSocketAddress (netPort)); //<--but here, this method (socket) is abstract. WHY RETURN A SOCKET????????  this mehod should be empty by default.
             System.out.print ("Waiting for connection on port "
                + netPort + "...");
             System.out.flush();
             ByteChannel channel = ssc.accept();
             ssc.close();
             System.out.println ("Got it");
             return (channel);
       } I test this code and works fine. So why can it be??
    Also, I read that the abstract classes can't have static methods. Is it true???
    Please Help!!
    PS: i have seen this kind of code many times. So i feel that I don't understand how its really the abstract methods are made.
    PS2: I understand that obviously you don't do something like this: *"obj = new AbstractClass(); "*. I dont understand how it could be: ServerSocketChannel ssc = ServerSocketChannel.open(); and the compiler didn't warn.

    molavec wrote:
    ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
    The static method creates an instance of a class which extends ServerSocketChannel, but is actually another non-abstract class.I thought that, but reading the documentation I saw that about open() method:
    Opens a server-socket channel.
    The new channel is created by invoking the openServerSocketChannel method of the system-wide default SelectorProvider object.
    The new channel's socket is initially unbound; it must be bound to a specific address via one of its socket's bind methods before connections can be accepted.
    ...and the problem is the same openServerSocketChannel is abstract, so i don't understand how it could return a ServerSocketChannel.There is a concrete implementation class that has implemented that method.
    I guess that really the open() method use a SelectorProvider's subclase but it doesn't appear in the doc.It doesn't need to. First, you don't care about those implementation details, and second, you know that if the class is abstract, it must use some concrete subclass.
    Ok, I speak Spanish by default (<-- this sounds like "I am a machine", ^_^' ). So, I didn't know how to say that the method would be {}. Is there a way to say that?? I recommendable for me to know, for the future questions o answers.Not sure what you're saying here. But the other respondent was trying to explain to you the difference between an abstract method and an empty method.
    // abstract method
    public abstract void foo();
    // empty method
    public void bar() {
    Which class does extend ServerSocketChannel? I can not see it.It may be a package-private class or a private nested class. There's no need to document that specific implementation, since you never need to use it directly.

Maybe you are looking for