named the s:element and s:complexType the same name

Junchen Liu

is it legal to name the s:element and s:complexType the same name? you can see the following code, the element and complextype has exactly the same name this is a chunk of wsdl file.

<s:element name="ProcessTaskActionResponse">
 <s:complexType>
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="ProcessTaskActionResult" type="tns:ProcessTaskActionResponse"/>
  </s:sequence>
 </s:complexType>
</s:element>

<s:complexType name="ProcessTaskActionResponse">
 <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="TaskId" type="tns:ArrayOfServerId"/>
    <s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean"/>
    <s:element minOccurs="0" maxOccurs="1" name="ActionPerformedLabel" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="Errors" type="tns:ArrayOfString"/>
    <s:element minOccurs="1" maxOccurs="1" name="RemovedFromTaskList" type="s:boolean"/>
 </s:sequence>
</s:complexType>
bdoughan

Yes, it is legal to have a complex type and element with the same name in an XML Schema.

Since your question is tagged with [java] and [web-services] you may be using JAXB (via JAX-WS) to generate classes from the XML Schema. In that case since a complex type and element (with an anonymous complex type) have the same name you will need to use an external binding file to rename one of the generated classes.


UPDATE

good guess! the JAXB parser thrown a exception, mainly because the naming conflict, my question is if its legal why the JAXB not liking it?

JAXB (JSR-222) converts complex types to Java classes. For named complex types the resulting class name is derived from the complex type name, for anonymous complex types the resulting class name is derived from the enclosing element. In your case this would result in two classes with the same name that JAXB complains about.

Rename Class Corresponding to the XML Element (binding.xml)

<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">

    <jxb:bindings schemaLocation="your-schema.xsd">
            <jxb:bindings node="//xs:element[@name='ProcessTaskActionResponse']/complexType">
                <jxb:class name="ProcessTaskActionResponseElement"/>
            </jxb:bindings>
    </jxb:bindings>

</jxb:bindings>

Rename Class Corresponding to the Complex Type (binding.xml)

<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">

    <jxb:bindings schemaLocation="your-schema.xsd">
            <jxb:bindings node="//xs:complexType[@name='ProcessTaskActionResponse']">
                <jxb:class name="ProcessTaskActionResponseType"/>
            </jxb:bindings>
    </jxb:bindings>

</jxb:bindings>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

named the s:element and s:complexType the same name

From Dev

XSD : ComplexType Element With the Same Name

From Dev

Can I give the same name to complexType and element - XSD Standards

From Dev

Can I give the same name to complexType and element - XSD Standards

From Dev

IE 7 raises error when variable name is same as the element id's name

From Dev

XSLT replace element with it's parent's name

From Dev

Accessing an element's parentNode, if the element has a child named parentNode

From Dev

Graph search for element by element's name in jointJS

From Dev

Make an element's width the same as another element

From Dev

The named parameter 'child' isn't defined. Try correcting the name to an existing named parameter's name

From Dev

Is there a way to create a named logger with NLog and filter logging by this name(s)?

From Dev

JavaScript - Difference beetween object's method named once and name twice

From Dev

Django: Named Url's/ Same regex, different Names

From Dev

Adding an element and it's class name via JS

From Dev

Replace the XML element's name with the value of an attribute

From Dev

How to get an option element's value by name

From Dev

switch div's with the same name css jquery

From Dev

Serialize form - input's with same name

From Dev

switch div's with the same name css jquery

From Dev

p element's length same as text in it?

From Dev

How to check if there's None in List[Option[_]] and return the element's name?

From Dev

NSFetchedResultsController's sections array element's name not updating correctly

From Dev

WPF Bind property to another element property by the element's name

From Dev

Moving files with the same name to matching named folders

From Dev

Unique constraint on a complexType instead of an element

From Dev

Wrap function parameters complexType in an element

From Dev

Set DOM element's attribute whose name does not match XML's Name production

From Dev

How to set an element's background-color to the value of that element's class name?

From Dev

tsql query soap get first element name after s:Body

Related Related

  1. 1

    named the s:element and s:complexType the same name

  2. 2

    XSD : ComplexType Element With the Same Name

  3. 3

    Can I give the same name to complexType and element - XSD Standards

  4. 4

    Can I give the same name to complexType and element - XSD Standards

  5. 5

    IE 7 raises error when variable name is same as the element id's name

  6. 6

    XSLT replace element with it's parent's name

  7. 7

    Accessing an element's parentNode, if the element has a child named parentNode

  8. 8

    Graph search for element by element's name in jointJS

  9. 9

    Make an element's width the same as another element

  10. 10

    The named parameter 'child' isn't defined. Try correcting the name to an existing named parameter's name

  11. 11

    Is there a way to create a named logger with NLog and filter logging by this name(s)?

  12. 12

    JavaScript - Difference beetween object's method named once and name twice

  13. 13

    Django: Named Url's/ Same regex, different Names

  14. 14

    Adding an element and it's class name via JS

  15. 15

    Replace the XML element's name with the value of an attribute

  16. 16

    How to get an option element's value by name

  17. 17

    switch div's with the same name css jquery

  18. 18

    Serialize form - input's with same name

  19. 19

    switch div's with the same name css jquery

  20. 20

    p element's length same as text in it?

  21. 21

    How to check if there's None in List[Option[_]] and return the element's name?

  22. 22

    NSFetchedResultsController's sections array element's name not updating correctly

  23. 23

    WPF Bind property to another element property by the element's name

  24. 24

    Moving files with the same name to matching named folders

  25. 25

    Unique constraint on a complexType instead of an element

  26. 26

    Wrap function parameters complexType in an element

  27. 27

    Set DOM element's attribute whose name does not match XML's Name production

  28. 28

    How to set an element's background-color to the value of that element's class name?

  29. 29

    tsql query soap get first element name after s:Body

HotTag

Archive