You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Rune Peter Bjørnstad <r....@student.utwente.nl> on 2004/02/05 21:55:57 UTC

Question/Suggestion

Hi,

 

My name is Rune Bjørnstad and I’m currently finishing my master thesis in
computer science at the University of Twente, the Netherlands. In my thesis
I am working with dynamic invocation of web services, and I’m currently
attacking various problems regarding type conversion. This is a typical
use-case of my application (all during runtime):

 

1.	Retrieve WSDL document from “somewhere”
2.	For every Message part, retrieve the XML Schema definition of the
type element. For example 

a.	The WSDL Message part looks like this: <part name=”name”
type=”types:Name”/>
b.	The XML Schema definition of type Name is:

<xsd:complexType name=”Name”>

                          <xsd:sequence>

                            <xsd:element name=”first” type=”xsd:string”/>  

                            <xsd:element name=”middle” minOccurs=”0”
type=”xsd:string”/>

                            <xsd:element name=”last” type=”xsd:string”/>

                          </xsd:sequence>

</xsd:complexType>

3.	Retrieve an XML String from the user that matches the Name type, for
example:

<input>

  <first>Rune</first>

                    <middle>Peter</middle>

        <last>Bjørnstad</last>

      </input>

4.	Parse the user string into an XmlObject and Validate it against the
type Name. This will not work in the current design?? Because the element
input is not defined. This should not be a requirement. What I want is to
validate that the element input is of type Name.

a.	If this is a desired feature, I’d be happy to contribute some code.

 

5.	I now want the root element to be of type Name, and the children of
type xsd:string. From what I have learned, only the root element gets a
type. I need something like this:

<input xsi:type=”Name”>

                        <first xsi:type=”xsd:string”>Rune</first>

                        <middle xsi:type=”xsd:string”>Peter</middle>

                        <last xsi:type=”xsd:string”>Bjørnstad</last>        

</input>  

a.	I see that you guys are aiming for a DOM representation. This
feature would fit in nicely. I’d be happy to contribute.

 

6.	With each element typed, without any schema compiled custom classes,
I have an in-memory representation of the input element, much like IBM’s
JROM. This representation I need to serialize and deserialize into a SOAP
request.

 

>From what I can see, XmlBeans focuses a lot on schema compilation and
marshalling into schema-derived compiled classes. With the brilliant schema
support, it should be possible to incorporate an in-memory representation
that integrates nicely. Is this a desired feature…. Or does it already
exist?

 

Kind Regards,

 

Rune Bjørnstad.

r.p.bjornstad@student.utwente.nl

 


RE: Question/Suggestion

Posted by Rune Peter Bjørnstad <r....@student.utwente.nl>.
A bit of a late response, but your suggestion worked perfectly. I was
viewing the XmlObject as the root element, and thus validating the object
Itself didn't work. With your suggestion I now have a typed
object-representation of an element, which I can serialize into a SOAP
message, using standard axis-serializers for simple-types, and a custom
XmlBeans serializer for complex-types. 

Thank you very much,

Rune.


-----Original Message-----
From: Kevin Krouse [mailto:kkrouse@bea.com] 
Sent: 7. februar 2004 02:13
To: xmlbeans-dev@xml.apache.org
Subject: Re: Question/Suggestion

On Thu, 2004-02-05 at 12:55, Rune Peter Bjørnstad wrote:

>      1. Parse the user string into an XmlObject and Validate it
>         against the type Name. This will not work in the current
>         design?? Because the element input is not defined. This should
>         not be a requirement. What I want is to validate that the
>         element input is of type Name.

Unfortunately, in v1 there is straight forward way to force an element
to be a particular schema type like you can with documents.  It might be
feature in v2...

So for now, the easiest thing to do is have another schema which defines
the input element as the "Name" type where you can parse and validate. 
An alternative is to get the contents of an XmlObject, create a copy,
and set the type to what you want:

        XmlObject o = XmlObject.Factory.parse(inputXml);
        XmlCursor c = o.newCursor();
        c.toFirstChild();
        o = c.getObject();
        o = o.copy();
        o = o.changeType(NameType.type);
        o.validate();

give that a try and let me know how it works for you...

--k

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/




- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


RE: Question/Suggestion

Posted by Rune Peter Bjørnstad <r....@student.utwente.nl>.
A bit of a late response, but your suggestion worked perfectly. I was
viewing the XmlObject as the root element, and thus validating the object
Itself didn't work. With your suggestion I now have a typed
object-representation of an element, which I can serialize into a SOAP
message, using standard axis-serializers for simple-types, and a custom
XmlBeans serializer for complex-types. 

Thank you very much,

Rune.


-----Original Message-----
From: Kevin Krouse [mailto:kkrouse@bea.com] 
Sent: 7. februar 2004 02:13
To: xmlbeans-dev@xml.apache.org
Subject: Re: Question/Suggestion

On Thu, 2004-02-05 at 12:55, Rune Peter Bjørnstad wrote:

>      1. Parse the user string into an XmlObject and Validate it
>         against the type Name. This will not work in the current
>         design?? Because the element input is not defined. This should
>         not be a requirement. What I want is to validate that the
>         element input is of type Name.

Unfortunately, in v1 there is straight forward way to force an element
to be a particular schema type like you can with documents.  It might be
feature in v2...

So for now, the easiest thing to do is have another schema which defines
the input element as the "Name" type where you can parse and validate. 
An alternative is to get the contents of an XmlObject, create a copy,
and set the type to what you want:

        XmlObject o = XmlObject.Factory.parse(inputXml);
        XmlCursor c = o.newCursor();
        c.toFirstChild();
        o = c.getObject();
        o = o.copy();
        o = o.changeType(NameType.type);
        o.validate();

give that a try and let me know how it works for you...

--k

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/




- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Question/Suggestion

Posted by Kevin Krouse <kk...@bea.com>.
On Thu, 2004-02-05 at 12:55, Rune Peter Bjørnstad wrote:

>      1. Parse the user string into an XmlObject and Validate it
>         against the type Name. This will not work in the current
>         design?? Because the element input is not defined. This should
>         not be a requirement. What I want is to validate that the
>         element input is of type Name.

Unfortunately, in v1 there is straight forward way to force an element
to be a particular schema type like you can with documents.  It might be
feature in v2...

So for now, the easiest thing to do is have another schema which defines
the input element as the "Name" type where you can parse and validate. 
An alternative is to get the contents of an XmlObject, create a copy,
and set the type to what you want:

        XmlObject o = XmlObject.Factory.parse(inputXml);
        XmlCursor c = o.newCursor();
        c.toFirstChild();
        o = c.getObject();
        o = o.copy();
        o = o.changeType(NameType.type);
        o.validate();

give that a try and let me know how it works for you...

--k

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Question/Suggestion

Posted by Kevin Krouse <kk...@bea.com>.
On Thu, 2004-02-05 at 12:55, Rune Peter Bjørnstad wrote:

>      1. Parse the user string into an XmlObject and Validate it
>         against the type Name. This will not work in the current
>         design?? Because the element input is not defined. This should
>         not be a requirement. What I want is to validate that the
>         element input is of type Name.

Unfortunately, in v1 there is straight forward way to force an element
to be a particular schema type like you can with documents.  It might be
feature in v2...

So for now, the easiest thing to do is have another schema which defines
the input element as the "Name" type where you can parse and validate. 
An alternative is to get the contents of an XmlObject, create a copy,
and set the type to what you want:

        XmlObject o = XmlObject.Factory.parse(inputXml);
        XmlCursor c = o.newCursor();
        c.toFirstChild();
        o = c.getObject();
        o = o.copy();
        o = o.changeType(NameType.type);
        o.validate();

give that a try and let me know how it works for you...

--k

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/