File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Significance of this tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Significance of this tag" Watch "Significance of this tag" New topic
Author

Significance of this tag

Amit G Piplani
Ranch Hand

Joined: Jul 21, 2004
Posts: 83
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


SCJP,SCWCD,SCBCD,SCDJWS1.4, SCDJWS1.5
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
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


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Hasan Pasha
Greenhorn

Joined: Feb 23, 2005
Posts: 25

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

Joined: Jul 21, 2004
Posts: 83
Thanks for your reply, but still why should i use NMToken, if i can set the value directly from Enumeration?
Hasan Pasha
Greenhorn

Joined: Feb 23, 2005
Posts: 25
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hi Hasan,

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

Thanks.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Amit G Piplani
Ranch Hand

Joined: Jul 21, 2004
Posts: 83
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Significance of this tag