Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Significance of this tag

 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone tell me what is the significance of this tag?

<xs:simpleType name="FinancedPaidCashValues">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="C"/>
<xs:enumeration value="F"/>
</xs:restriction>
</xs:simpleType>

Amit
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a tag that is used in Schema definition files. It is used to define a type of an element (much like defining your own type for a variable in Java/C++/C/?whatever?).

In this case, it is defining a type called FinancedPaidCashValues. Further, it is restricting the values a variable of this type can have to the listed values, namely - C and F.

The tag simpleType further declares that an element of this type can not have child elements (or attributes? I think :-scrathcing my head-: ). The simpleType tag is defined in the Schema recommendations.

- m
 
Hasan Pasha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The tag simpleType further declares that an element of this type can not have child elements (or attributes? I think :-scrathcing my head-: ). The simpleType tag is defined in the Schema recommendations.


Simple Type - Can be an element which does not have child element(s) or any attributes.
Any attribute is always of simple type as it cannot have child elements!

Complex Type - An element either has attribute(s) or child element(s).

An element with an attribute is declared using the 'simpleContent' XML schema tag.
 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, but still why should i use NMToken, if i can set the value directly from Enumeration?
 
Hasan Pasha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NMToken is a 1 of the 10 datatypes available with DTDs.

In order to maintain consistency between DTDs and W3C XML Schema, they were added as a part of the 44 built-in datatypes. NMToken can be applied only to attributes.

There is nothing binding you to select NMToken datatype, except ofcourse it was planed to retain the same datatype which was available in the DTD (while migrating to W3C XML Schema from DTD).
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hasan,

Would you mind editing your display name a bit so that it complies with our naming policy?

Thanks.
 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Adding to NMToken, I am pasting my axis generated class :
public class FulfillmentTypeValues implements java.io.Serializable {
private org.apache.axis.types.NMToken _value_;
private static java.util.HashMap _table_ = new java.util.HashMap();

// Constructor
protected FulfillmentTypeValues(org.apache.axis.types.NMToken value) {
_value_ = value;
_table_.put(_value_,this);
}

public static final org.apache.axis.types.NMToken _P = new org.apache.axis.types.NMToken("P");
public static final FulfillmentTypeValues P = new FulfillmentTypeValues(_P);
public org.apache.axis.types.NMToken getValue() { return _value_;}
public static FulfillmentTypeValues fromValue(org.apache.axis.types.NMToken value)
throws java.lang.IllegalStateException {
FulfillmentTypeValues enum = (FulfillmentTypeValues)
_table_.get(value);
if (enum==null) throw new java.lang.IllegalStateException();
return enum;
}
public static FulfillmentTypeValues fromString(java.lang.String value)
throws java.lang.IllegalStateException {
try {
return fromValue(new org.apache.axis.types.NMToken(value));
} catch (Exception e) {
throw new java.lang.IllegalStateException();
}
}
public boolean equals(java.lang.Object obj) {return (obj == this);}
public int hashCode() { return toString().hashCode();}
public java.lang.String toString() { return _value_.toString();}
public java.lang.Object readResolve() throws java.io.ObjectStreamException { return fromValue(_value_);}
}

When i am trying to set FulfillmentTypeValues using NMToken class or using its static methods, i am getting following runtime exception :
org.xml.sax.SAXException: Failed to marshal FulfillmentType Msg:I
legal Text data found as child of: FulfillmentType
value: "P"

Any help/advice will be highly appreicated.

Amit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic