::::::::::::::
basket.xsd
::::::::::::::
::::::::::::::
basket/X2J.cd
::::::::::::::
import java.util.*;
import java.io.*;
import edu.neu.ccs.demeter.dj.*;
// *************************************************************************
// The following section has been generated automatically by the XML to Java
// conversion application.
// *************************************************************************
XMLDoc = " String "?>"
" basketType "".
basketType = ">"
List(contentListUnit).
contentListUnit = " fruit "".
fruit : apple | orange.
XMLpositiveInteger = int.
apple = [ "color" "=" String ]
">"
"" XMLpositiveInteger ""
"" String "".
orange = ">"
"" XMLpositiveInteger ""
"" String "".
Main = .
Preprocessor = .
List(S) ~ {S}.
ValidateVisitor = extends Visitor.
// *************************************************************************
// End of automatically generated section.
// *************************************************************************
::::::::::::::
basket/X2Jdoc.beh
::::::::::::::
XMLDoc {
public static XMLDoc XMLparse(String in) throws Exception
{{
XMLDoc doc = parse(Preprocessor.process(in));
doc.validate();
return doc;
}}
public static XMLDoc XMLParse(InputStream in) throws Exception
{{
return XMLparse(Preprocessor.process(readContent(in)));
}}
public static XMLDoc XMLParse(Reader in) throws Exception
{{
return XMLparse(Preprocessor.process(readContent(in)));
}}
private static String readContent(Reader in) throws Exception
{{
BufferedReader r = new BufferedReader(in);
String text = "";
try {
while (true)
{
String line = r.readLine();
if (line == null) break;
if (!text.equals("")) text = text + "\n";
text = text + line;
}
r.close();
return text;
}
catch (IOException e) {
throw new Exception("Error in reading input");
}
}}
private static String readContent(InputStream in) throws Exception
{{
String text = "";
try {
byte buf[] = new byte[1000];
while (true)
{
int size = in.read(buf);
if (size <= 0) break;
String line = new String(buf, 0, size);
if (!text.equals("")) text = text + "\n";
text = text + line;
}
in.close();
return text;
}
catch (IOException e) {
throw new Exception("Error in reading input");
}
}}
public void validate() throws Exception bypassing -> *,tail,* to * (ValidateVisitor);
} // end of class XMLDoc
::::::::::::::
basket/X2Jvalidate.beh
::::::::::::::
ValidateVisitor {
public void start() {{
}}
public void before(XMLpositiveInteger host) throws Exception {{
if (host.get_value() < 1)
throw new Exception ("Value of element 'value' is < 1.");
}}
} // end of class ValidateVisitor