IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Two different ways to declare an attribute

  • 1.  Two different ways to declare an attribute

    Posted Fri May 07, 2004 09:33 PM

    Hello everyone!

    I was hoping someone could clarify to me the difference between these two, in TDS schemas (not XSD).
    Basically I am defining an element with an attribute.


    In GUI, this was generated by inserting a complex element to the schema and then adding an attribute:

    <xs:element name = “full”>
    xs:complexType
    <xs:attribute name = “width” type = “xs:positiveInteger” use = “required”></xs:attribute>
    </xs:complexType>
    </xs:element>

    ----------------------

    In GUI, this was generated by inserting an “element with attributes” to the schema and then adding an attribute

    <xs:element name = “full”>
    xs:complexType
    xs:simpleContent
    xs:extension
    <xs:attribute name = “width” type = “xs:positiveInteger” use = “required”></xs:attribute>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>


    What I would liek to know is why these two exist? Is there a difference in terms of speed or anything else when Tamino validates the node against an instance?

    I am evaluating a software called “Stylus Studio”, so that I could print these schemas graphically (I own XmlSpy, but that one doesn’t print attributes, period!), and the software won’t graphically render attributes if they are declared within xs:extension. So I am thinking I will use only complex elements from now on and not the “element with attributes”, if, there is no real difference.


    Thank you very much

    Peter Endisch

    ---------------------------------------
    I’m a Zen Garden Maintenance Engineer
    ---------------------------------------


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: Two different ways to declare an attribute

    Posted Tue May 11, 2004 08:02 PM

    Hello everyone

    I poked around a lot and I guess I answered my own question. I thought I’d share it with you, in case it helps someone. Furthermore, if I am wrong about my assumption, you are more then welcome to correct me. I don’t claim to understand everything perfectly.


    A complex element cannot really have a “value”.
    You can force it to accept a “value” by using “mixed:true”. By doing that, you can have both subnodes and a textual value.
    ex:


    textual value, thanks to mixed:true
    subnode-value


    However, by doing this, you cannot declare a datatype for the textual value. This is, obviously a huge problem, and I think therefore that mixed:true should be used sparingly (for instance, if you want to have a node that contains a description (xhtml), and you don’t know how many subnodes and or text you will have).

    On the other hand, “element with attributes” is great when the node you’re using is a leaf node and it will also have attributes. You can of course declare a datatype for the value of the node.

    Lastly, if you want to have a node that has no subnodes, and has NO TEXTUAL VALUE of any sort, but you want it to have attributes (great for nodes that have attributes representing foreign keys), then I find using a complex element with attributes, and no subnodes and mixe:false is the best thing.
    That way, the schema doesn’t allow any value for the node (just the attribs).

    Any thoughts?

    Peter Endisch

    ---------------------------------------
    I’m a Zen Garden Maintenance Engineer
    ---------------------------------------


    #API-Management
    #webMethods
    #Tamino