Call hasFeature("AS-EDIT", "3.0")
to verify that
this is supported
Load a DOMImplementation
in the usual way
Cast DOMImplementation
to DOMImplementationAS
Invoke the createAS()
method to create a new,
implementation-specific
ASModel
object
Use the factory methods in this
ASModel
to create the schema
try {
if (impl.hasFeature("AS-EDIT", "3.0")) {
DOMImplementationFactoryLS impl =
(DOMImplementationAS) DOMImplementationFactory.getDOMImplementation();
ASModel dtd = impl.createAS(false, "DTD");
// <!ELEMENT methodCall (methodName, params)>
ASElementDecl methodCall = dtd.createASElementDecl(null, "methodCall");
ASContentModel methodCallModel = dtd.createASContentModel(
"methodCall", null, 1, 1, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(methodCallModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT methodName (#PCDATA)>
ASElementDecl methodName = dtd.createASElementDecl(null, "methodName");
methodName.setIsPCDataOnly(true);
// <!ELEMENT params (param*)>
ASElementDecl params = dtd.createASElementDecl(null, "params");
ASContentModel paramsModel = dtd.createASContentModel(
"params", "", 0, ASContentModel.AS_UNBOUNDED, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(paramsModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT param (value)>
ASElementDecl param = dtd.createASElementDecl(null, "param");
ASContentModel paramModel = dtd.createASContentModel(
"param", "", 1, 1, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(paramModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT value (i4|int|string|dateTime.iso8601|double|base64|struct|array)>
ASElementDecl value = dtd.createASElementDecl(null, "value");
ASContentModel valueModel = dtd.createASContentModel(
"param", "", 1, 1, ASContentModel.AS_CHOICE);
methodCall.setASContentModel(valueModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT i4 (#PCDATA)>
// <!ELEMENT int (#PCDATA)>
// <!ELEMENT string (#PCDATA)>
// <!ELEMENT dateTime.iso8601 (#PCDATA)>
// <!ELEMENT double (#PCDATA)>
// <!ELEMENT base64 (#PCDATA)>
ASElementDecl i4 = dtd.createASElementDecl(null, "i4");
i4.setIsPCDataOnly(true);
ASElementDecl intElement = dtd.createASElementDecl(null, "int");
intElement.setIsPCDataOnly(true);
ASElementDecl string = dtd.createASElementDecl(null, "string");
string.setIsPCDataOnly(true);
ASElementDecl dateTime.iso8601 = dtd.createASElementDecl(null, "dateTime.iso8601");
dateTime.iso8601.setIsPCDataOnly(true);
ASElementDecl base64 = dtd.createASElementDecl(null, "base64");
base64.setIsPCDataOnly(true);
ASElementDecl doubleElement = dtd.createASElementDecl(null, "doubleElement");
doubleElement.setIsPCDataOnly(true);
// <!ELEMENT array (data)>
ASElementDecl array = dtd.createASElementDecl(null, "array");
ASContentModel arrayModel = dtd.createASContentModel(
"array", "", 1, ASContentModel.AS_UNBOUNDED, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(arrayModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT data (value*)>
ASElementDecl data = dtd.createASElementDecl(null, "data");
ASContentModel dataModel = dtd.createASContentModel(
"data", "", 0, 1, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(arrayModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT struct (member+)>
ASElementDecl struct = dtd.createASElementDecl(null, "struct");
ASContentModel structModel = dtd.createASContentModel(
"struct", "", 1, ASContentModel.AS_UNBOUNDED, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(structModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT member (name, value)>
ASElementDecl member = dtd.createASElementDecl(null, "member");
ASContentModel memberModel = dtd.createASContentModel(
"member", "", 2, 2, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(memberModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT name (#PCDATA)>
ASElementDecl name = dtd.createASElementDecl(null, "i4");
name.setIsPCDataOnly(true);
// <!ELEMENT methodResponse (params | fault)>
ASElementDecl methodResponse = dtd.createASElementDecl(null, "methodResponse");
ASContentModel methodResponseModel = dtd.createASContentModel(
"member", "", 1, 1, ASContentModel.AS_CHOICE);
methodCall.setASContentModel(methodResponseModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
// <!ELEMENT fault (value)>
ASElementDecl fault = dtd.createASElementDecl(null, "fault");
ASContentModel faultModel = dtd.createASContentModel(
"fault", "", 1, 1, ASContentModel.AS_SEQUENCE);
methodCall.setASContentModel(faultModel);
methodCall.setContentType(ASElementDecl.ELEMENTS_CONTENTTYPE);
methodCallModel.appendSubModel(methodName);
methodCallModel.appendSubModel(params);
paramsModel.appendSubModel(param);
paramModel.appendSubModel(value);
valueModel.appendSubModel(i4);
valueModel.appendSubModel(intElement);
valueModel.appendSubModel(string);
valueModel.appendSubModel(dateTime.iso8601);
valueModel.appendSubModel(doubleElement);
valueModel.appendSubModel(base64Element);
valueModel.appendSubModel(structElement);
valueModel.appendSubModel(arrayElement);
arrayModel.appendSubModel(data);
dataModel.appendSubModel(value);
structModel.appendSubModel(name);
methodResponseModel.appendSubModel(params);
methodResponseModel.appendSubModel(fault);
memberModel.appendSubModel(name);
memberModel.appendSubModel(value);
faultModel.appendSubModel(value);
}
}
catch (ASException e) {
System.err.println(e);
}