You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2006/11/24 13:15:06 UTC
svn commit: r478855 [9/21] - in /webservices/jaxme/branches/MAVEN/jaxme-xs:
./ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/ws/
src/main/java/org/apache/ws/jaxme/ src/main/java/org/apache/ws/jaxme/...
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSString.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSString.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSString.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSString.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The type xs:string.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSString extends AbstractAtomicType {
+ private static final XSString theInstance = new XSString();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "string", null);
+
+ protected XSString() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public boolean isRestriction() { return true; }
+ public XSType getRestrictedType() { return XSAnySimpleType.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSTime.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSTime.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSTime.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSTime.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The type xs:time.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSTime extends AbstractAtomicType {
+ private static final XSTime theInstance = new XSTime();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "time", null);
+
+ protected XSTime() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public boolean isRestriction() { return true; }
+ public XSType getRestrictedType() { return XSAnySimpleType.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSToken.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSToken.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSToken.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSToken.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+/** <p>The xs:token type.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSToken extends XSNormalizedString {
+ private static final XSToken theInstance = new XSToken();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "token", null);
+
+ protected XSToken() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public boolean isCollapsing() { return true; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public XSType getRestrictedType() { return XSNormalizedString.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedByte.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedByte.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedByte.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedByte.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The xs:unsignedByte type</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSUnsignedByte extends XSUnsignedShort {
+ private static final XSUnsignedByte theInstance = new XSUnsignedByte();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "unsignedByte", null);
+
+ protected XSUnsignedByte() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public String getMaxInclusive() { return "255"; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public XSType getRestrictedType() { return XSUnsignedShort.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedInt.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedInt.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedInt.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedInt.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The xs:unsignedInt type</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSUnsignedInt extends XSUnsignedLong {
+ private static final XSUnsignedInt theInstance = new XSUnsignedInt();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "unsignedInt", null);
+
+ protected XSUnsignedInt() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public String getMaxInclusive() { return "4294967295"; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public XSType getRestrictedType() { return XSUnsignedLong.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedLong.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedLong.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedLong.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedLong.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The xs:unsignedLong type</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSUnsignedLong extends XSNonNegativeInteger {
+ private static final XSUnsignedLong theInstance = new XSUnsignedLong();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "unsignedLong", null);
+
+ protected XSUnsignedLong() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public String getMaxInclusive() { return "18446744073709551615"; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public XSType getRestrictedType() { return XSNonNegativeInteger.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedShort.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedShort.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedShort.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/XSUnsignedShort.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.types;
+
+import org.apache.ws.jaxme.xs.XSParser;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+
+
+/** <p>The xs:unsignedShort type</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSUnsignedShort extends XSUnsignedInt {
+ private static final XSUnsignedShort theInstance = new XSUnsignedShort();
+ private static final XsQName name = new XsQName(XSParser.XML_SCHEMA_URI, "unsignedShort", null);
+
+ protected XSUnsignedShort() {
+ }
+
+ public XsQName getName() { return name; }
+
+ public String getMaxInclusive() { return "65535"; }
+
+ public static XSType getInstance() { return theInstance; }
+
+ public XSType getRestrictedType() { return XSUnsignedInt.getInstance(); }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/package.html
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/package.html?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/package.html (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/types/package.html Fri Nov 24 04:14:48 2006
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+ <head>
+ <title>
+Package Documentation for org.apache.ws.jaxme.xs.types Package
+ </title>
+</head>
+ <body bgcolor="white">
+ <p>
+XML schema data type models.
+ </p>
+</body>
+</html>
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/DTDParser.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/DTDParser.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/DTDParser.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/DTDParser.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,798 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.jaxme.xs.util;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.ws.jaxme.xs.XSSchema;
+import org.apache.ws.jaxme.xs.impl.XSLogicalParser;
+import org.apache.ws.jaxme.xs.parser.XSContext;
+import org.apache.ws.jaxme.xs.parser.impl.XSContextImpl;
+import org.apache.ws.jaxme.xs.types.XSAnyType;
+import org.apache.ws.jaxme.xs.types.XSEntities;
+import org.apache.ws.jaxme.xs.types.XSEntity;
+import org.apache.ws.jaxme.xs.types.XSID;
+import org.apache.ws.jaxme.xs.types.XSIDREF;
+import org.apache.ws.jaxme.xs.types.XSIDREFs;
+import org.apache.ws.jaxme.xs.types.XSNMToken;
+import org.apache.ws.jaxme.xs.types.XSNMTokens;
+import org.apache.ws.jaxme.xs.types.XSNotation;
+import org.apache.ws.jaxme.xs.types.XSString;
+import org.apache.ws.jaxme.xs.xml.XsAGOccurs;
+import org.apache.ws.jaxme.xs.xml.XsAnyURI;
+import org.apache.ws.jaxme.xs.xml.XsEChoice;
+import org.apache.ws.jaxme.xs.xml.XsEComplexContent;
+import org.apache.ws.jaxme.xs.xml.XsEEnumeration;
+import org.apache.ws.jaxme.xs.xml.XsERestriction;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsESimpleContent;
+import org.apache.ws.jaxme.xs.xml.XsGAttrDecls;
+import org.apache.ws.jaxme.xs.xml.XsNCName;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTAttribute;
+import org.apache.ws.jaxme.xs.xml.XsTComplexType;
+import org.apache.ws.jaxme.xs.xml.XsTExplicitGroup;
+import org.apache.ws.jaxme.xs.xml.XsTExtensionType;
+import org.apache.ws.jaxme.xs.xml.XsTLocalComplexType;
+import org.apache.ws.jaxme.xs.xml.XsTLocalElement;
+import org.apache.ws.jaxme.xs.xml.XsTLocalSimpleType;
+import org.apache.ws.jaxme.xs.xml.XsTSimpleExtensionType;
+import org.apache.ws.jaxme.xs.xml.XsTTopLevelElement;
+import org.apache.ws.jaxme.xs.xml.impl.XsESchemaImpl;
+import org.apache.ws.jaxme.xs.xml.impl.XsObjectFactoryImpl;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.helpers.LocatorImpl;
+
+
+/** A SAX parser converting a DTD into an instance of XML Schema.
+ */
+public class DTDParser extends XSLogicalParser {
+ /** This class is used to collect the attributes in the
+ * DTD temporarily.
+ */
+ public class DTDAttribute {
+ private final String name, type, mode, value;
+ private final Locator loc;
+ /** Sets the attributes name.
+ */
+ public DTDAttribute(String pName, String pType, String pMode, String pValue) {
+ name = pName;
+ type = pType;
+ mode = pMode;
+ value = pValue;
+ Locator l = DTDParser.this.getLocator();
+ if (l == null) {
+ loc = null;
+ } else {
+ loc = new LocatorImpl(l);
+ }
+ }
+ /** Returns the attributes name.
+ */
+ public String getName() {
+ return name;
+ }
+ /** Returns the attributes type.
+ */
+ public String getType() {
+ return type;
+ }
+ /** Returns the attributes mode.
+ */
+ public String getMode() {
+ return mode;
+ }
+ /** Returns the attributes value.
+ */
+ public String getValue() {
+ return value;
+ }
+ /** Returns the attributes locator.
+ */
+ public Locator getLocator() {
+ return loc;
+ }
+ }
+
+ /** This class is used to collect the elements in the
+ * DTD temporarily.
+ */
+ public class DTDElement {
+ private final String name;
+ private Locator loc;
+ private String model;
+ private Map attributes = new HashMap();
+ /** Creates a new element declaration with the given name.
+ */
+ public DTDElement(String pName) {
+ name = pName;
+ }
+ /** Sets the elements content model.
+ */
+ public void setModel(String pModel) {
+ Locator l = DTDParser.this.getLocator();
+ if (l == null) {
+ loc = null;
+ } else {
+ loc = new LocatorImpl(l);
+ }
+ model = pModel;
+ }
+ /** Returns the elements content model.
+ */
+ public String getModel() {
+ return model;
+ }
+ /** Returns the elements name.
+ */
+ public String getName() {
+ return name;
+ }
+ /** Adds a new attribute to the element.
+ */
+ public void addAttribute(DTDAttribute pAttribute) throws SAXException {
+ if (attributes.put(pAttribute.getName(), pAttribute) != null) {
+ throw new SAXParseException("Duplicate attribute " + pAttribute.getName()
+ + " in element " + getName(),
+ pAttribute.getLocator());
+ }
+ }
+ /** Returns the elements attributes.
+ */
+ public DTDAttribute[] getAttributes() {
+ return (DTDAttribute[]) attributes.values().toArray(new DTDAttribute[attributes.size()]);
+ }
+ /** Returns the elements locator.
+ */
+ public Locator getLocator() {
+ return loc;
+ }
+ }
+
+ protected static class ChildToken {
+ /** Type of a NAME token; see
+ * {@link DTDParser#parseChildren(XsTTopLevelElement, String, Locator)}
+ * for the definition of SEQUENCE.
+ */
+ public final static int SEQUENCE = 1;
+ /** Type of a NAME token; see
+ * {@link DTDParser#parseChildren(XsTTopLevelElement, String, Locator)}
+ * for the definition of CHOICE.
+ */
+ public final static int CHOICE = 2;
+ private final int type;
+ private final List tokens = new ArrayList();
+ private final String multiplicity;
+ protected ChildToken(int pType, String pMultiplicity) {
+ type = pType;
+ multiplicity = pMultiplicity;
+ }
+ /** Returns the token type; either of
+ * {@link #SEQUENCE}, or {@link #CHOICE}.
+ */
+ public int getType() { return type; }
+ /** Adds a token to the list of tokens.
+ */
+ public void add(ChildToken pToken) {
+ tokens.add(pToken);
+ }
+ /** Adds a name to the list of tokens.
+ */
+ public void add(String pName) {
+ tokens.add(pName);
+ }
+ /** Returns the tokens childs.
+ */
+ public Object[] getChilds() {
+ return tokens.toArray();
+ }
+ /** Returns the tokens multiplicity.
+ */
+ public String getMultiplicity() {
+ return multiplicity;
+ }
+ }
+
+ /** This class is similar to a StringReader, except that
+ * it allows to extend the input dynamically.
+ */
+ public static class StringBufferReader extends Reader {
+ private final StringBuffer sb = new StringBuffer();
+
+ /** Appends the given string to the input.
+ */
+ public void append(String pString) {
+ sb.append(pString);
+ }
+
+ /** Invoked, if the internal buffer is empty.
+ * Subclasses may override this to query for more
+ * input.
+ */
+ public String requestInput() {
+ return null;
+ }
+
+ public int read(char[] pBuffer, int pOffset, int pLen) throws IOException {
+ if (sb.length() == 0) {
+ String s = requestInput();
+ if (s != null && s.length() > 0) {
+ append(s);
+ }
+ if (sb.length() == 0) {
+ return -1;
+ }
+ }
+ if (pLen >= sb.length()) {
+ pLen = sb.length();
+ }
+ for (int i = 0; i < pLen; i++) {
+ pBuffer[pOffset+i] = sb.charAt(i);
+ }
+ sb.delete(0, pLen);
+ return pLen;
+ }
+
+ public void close() throws IOException {
+ }
+ }
+
+ /** Implementation of a {@link DeclHandler} for reading
+ * the element and attribute declarations.
+ */
+ public class DtdDeclHandler extends DefaultHandler implements DeclHandler {
+ public void setDocumentLocator(Locator pLocator) {
+ setLocator(pLocator);
+ }
+
+ public void elementDecl(String pName, String pModel) throws SAXException {
+ DTDElement element = (DTDElement) elements.get(pName);
+ if (element == null) {
+ element = new DTDElement(pName);
+ elements.put(pName, element);
+ } else {
+ if (element.getModel() != null) {
+ throw new SAXParseException("Element " + pName
+ + " declared twice", getLocator());
+ }
+ }
+ element.setModel(pModel);
+ }
+
+ public void attributeDecl(String pElementName, String pAttributeName,
+ String pType, String pMode, String pValue) throws SAXException {
+ DTDElement element = (DTDElement) elements.get(pElementName);
+ if (element == null) {
+ element = new DTDElement(pElementName);
+ elements.put(pElementName, element);
+ }
+ DTDAttribute attr = new DTDAttribute(pAttributeName, pType, pMode, pValue);
+ element.addAttribute(attr);
+ }
+
+ public void internalEntityDecl(String pName, String pValue) throws SAXException {
+ }
+
+ public void externalEntityDecl(String pName, String publicId, String pSystemId) throws SAXException {
+ }
+ }
+
+ private Locator locator;
+ private final Map elements = new HashMap();
+ private String dummyElementName;
+ private XsAnyURI targetNamespace;
+ private XSContext context;
+
+ public XSContext getData() {
+ return context;
+ }
+
+ /** Returns the document locator.
+ */
+ public Locator getLocator() {
+ return locator;
+ }
+
+ /** Sets the document locator.
+ */
+ public void setLocator(Locator pLocator) {
+ locator = pLocator;
+ XSContext context = getData();
+ if (context != null) {
+ context.setLocator(pLocator);
+ }
+ }
+
+ protected String getDummyElementName() {
+ if (dummyElementName == null) {
+ for (int i = 0; ; i++) {
+ String name = "dummyElement" + i;
+ if (!elements.containsKey(name)) {
+ dummyElementName = name;
+ break;
+ }
+ }
+ }
+ return dummyElementName;
+ }
+
+ /** Parses the given DTD, filling the parsers
+ * temporary map of elements.
+ */
+ protected void runXMLReader(final InputSource pSource)
+ throws ParserConfigurationException, IOException, SAXException {
+ /* We cannot parse the DTD directly. Instead, we create
+ * a dummy XML document, which references the DTD as
+ * an external entity, and parse the XML document.
+ */
+ String s = "<!DOCTYPE a SYSTEM 'uri:dtd'><a/>";
+ InputSource isource = new InputSource(new StringReader(s));
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setValidating(false);
+ XMLReader xr = spf.newSAXParser().getXMLReader();
+ xr.setEntityResolver(new EntityResolver(){
+ public InputSource resolveEntity(String publicId, String pSystemId) throws SAXException, IOException {
+ return "uri:dtd".equals(pSystemId) ? pSource : null;
+ }
+ });
+ DtdDeclHandler handler = new DtdDeclHandler();
+ xr.setContentHandler(handler);
+ xr.setProperty("http://xml.org/sax/properties/declaration-handler", handler);
+ xr.parse(isource);
+ }
+
+ private ChildToken addToChildToken(ChildToken pToken, String pTokenValue,
+ String pMultiplicity, int pType,
+ Locator pLocator)
+ throws SAXException {
+ if ("".equals(pTokenValue)) {
+ throw new SAXParseException("Expected name, choice, or sequence, found empty string", pLocator);
+ }
+ if (pToken == null) {
+ pToken = new ChildToken(pType, pMultiplicity);
+ } else {
+ if (pType != pToken.getType()) {
+ throw new SAXParseException("Mixed use of ',' and '|' in a choice or sequence", pLocator);
+ }
+ }
+ if (pTokenValue.startsWith("(")) {
+ pToken.add(parseChildren(pTokenValue, pLocator));
+ } else {
+ pToken.add(pTokenValue);
+ }
+ return pToken;
+ }
+
+ /** Returns a tokens multiplicity.
+ */
+ protected String getMultiplicity(String pToken) {
+ if (pToken.endsWith("*")) {
+ return "*";
+ } else if (pToken.endsWith("?")) {
+ return "?";
+ } else if (pToken.endsWith("+")) {
+ return "+";
+ } else {
+ return "";
+ }
+ }
+
+ /** Converts a list of children into its tokens.
+ */
+ protected ChildToken parseChildren(String pModel, Locator pLocator)
+ throws SAXException {
+ String model = pModel;
+ if (model.startsWith("(")) {
+ model = model.substring(1).trim();
+ } else {
+ throw new SAXParseException("A choice or sequence must start with '('",
+ pLocator);
+ }
+ String multiplicity = getMultiplicity(model);
+ model = model.substring(0, model.length() - multiplicity.length()).trim();
+ if (model.endsWith(")")) {
+ model = model.substring(0, model.length()-1);
+ } else {
+ throw new SAXParseException("A choice or sequence must end with ')', ')?', ')*', or ')+'",
+ pLocator);
+ }
+ ChildToken ct = null;
+ int level = 0;
+ int offset = 0;
+ for (int i = 0; i < model.length(); i++) {
+ char c = model.charAt(i);
+ switch (c) {
+ case '(': ++level; break;
+ case ')': --level; break;
+ case '|':
+ case ',':
+ if (level == 0) {
+ String t = model.substring(offset, i).trim();
+ ct = addToChildToken(ct, t, multiplicity,
+ (c == '|' ? ChildToken.CHOICE : ChildToken.SEQUENCE),
+ pLocator);
+ offset = i+1;
+ }
+ }
+ }
+ String t = model.substring(offset).trim();
+ return addToChildToken(ct, t, multiplicity,
+ ct == null ? ChildToken.SEQUENCE : ct.getType(),
+ pLocator);
+ }
+
+ /** Sets the objects multiplicity.
+ */
+ protected void setMultiplicity(XsAGOccurs pOccurs, String pMultiplicity) {
+ if ("?".equals(pMultiplicity)) {
+ pOccurs.setMinOccurs(0);
+ } else if ("*".equals(pMultiplicity)) {
+ pOccurs.setMinOccurs(0);
+ pOccurs.setMaxOccurs("unbounded");
+ } else if ("+".equals(pMultiplicity)) {
+ pOccurs.setMaxOccurs("unbounded");
+ } else if (!"".equals(pMultiplicity)) {
+ throw new IllegalArgumentException("Invalid multiplicity: " + pMultiplicity);
+ }
+ }
+
+ /** Adds the childs to a group.
+ */
+ protected void addChildren(XsTTopLevelElement pElement,
+ XsTExplicitGroup pGroup, ChildToken pToken,
+ Locator pLocator)
+ throws SAXException {
+ setMultiplicity(pGroup, pToken.getMultiplicity());
+ Object[] tokens = pToken.getChilds();
+ for (int i = 0; i < tokens.length; i++) {
+ Object o = tokens[i];
+ if (o instanceof String) {
+ String name = (String) o;
+ String multiplicity = getMultiplicity(name);
+ name = name.substring(0, name.length()-multiplicity.length()).trim();
+ if (!elements.containsKey(name)) {
+ throw new SAXParseException("Element " + pElement.getName()
+ + " references an undeclared element " + name,
+ pLocator);
+ }
+ XsTLocalElement e = pGroup.createElement();
+ e.setRef(new XsQName(getTargetNamespace(), getLocalPart(name)));
+ setMultiplicity(e, multiplicity);
+ } else if (o instanceof ChildToken) {
+ ChildToken ct = (ChildToken) o;
+ XsTExplicitGroup group;
+ if (ct.type == ChildToken.SEQUENCE) {
+ group = pGroup.createSequence();
+ } else {
+ group = pGroup.createChoice();
+ }
+ addChildren(pElement, group, ct, pLocator);
+ } else {
+ throw new IllegalStateException("Unknown token type: " + tokens[i].getClass().getName());
+ }
+ }
+ }
+
+ /** Parses a content model with children. This content
+ * model is specified as follows:
+ * <pre>
+ * children ::= (choice | seq) ('?' | '*' | '+')?
+ * cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ * choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'
+ * seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
+ * </pre>
+ */
+ protected XsGAttrDecls parseChildren(XsTTopLevelElement pElement, String pModel,
+ Locator pLocator) throws SAXException {
+ ChildToken ct = parseChildren(pModel, pLocator);
+ XsTLocalComplexType complexType = pElement.createComplexType();
+ XsTExplicitGroup group;
+ if (ct.getType() == ChildToken.SEQUENCE) {
+ group = complexType.createSequence();
+ } else {
+ group = complexType.createChoice();
+ }
+ addChildren(pElement, group, ct, pLocator);
+ return complexType;
+ }
+
+ /** Parses a mixed content model. The mixed content model
+ * is specified as follows:
+ * <pre>
+ * Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*'
+ * | '(' S? '#PCDATA' S? ')'
+ * </pre>
+ */
+ protected XsGAttrDecls parseMixed(XsTTopLevelElement pElement, String pModel,
+ Locator pLocator, boolean pHasAttributes)
+ throws SAXException {
+ if (!pModel.startsWith("(")) {
+ throw new SAXParseException("Mixed content model must start with '(#PCDATA'",
+ pLocator);
+ }
+ pModel = pModel.substring(1).trim();
+ if (!pModel.startsWith("#PCDATA")) {
+ throw new SAXParseException("Mixed content model must start with '(#PCDATA'",
+ pLocator);
+ }
+ pModel = pModel.substring("#PCDATA".length()).trim();
+ boolean unbounded;
+ if (pModel.endsWith("*")) {
+ pModel = pModel.substring(0, pModel.length()-1).trim();
+ unbounded = true;
+ } else {
+ unbounded = false;
+ }
+ if (!pModel.endsWith(")")) {
+ throw new SAXParseException("Mixed content model must end with ')' or ')*'",
+ pLocator);
+ }
+ pModel = pModel.substring(0, pModel.length()-1);
+ if ("".equals(pModel)) {
+ XsQName qName = XSString.getInstance().getName();
+ qName = new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs");
+ if (pHasAttributes) {
+ XsTLocalComplexType complexType = pElement.createComplexType();
+ XsESimpleContent simpleContent = complexType.createSimpleContent();
+ XsTSimpleExtensionType ext = simpleContent.createExtension();
+ ext.setBase(qName);
+ return ext;
+ } else {
+ pElement.setType(qName);
+ return null;
+ }
+ } else if (!unbounded) {
+ throw new SAXParseException("Mixed content must be either #PCDATA or have multiplicity '*'",
+ pLocator);
+ } else {
+ XsTLocalComplexType complexType = pElement.createComplexType();
+ complexType.setMixed(true);
+ XsEChoice choice = complexType.createChoice();
+ choice.setMinOccurs(0);
+ choice.setMaxOccurs("unbounded");
+ while (!"".equals(pModel)) {
+ if (pModel.startsWith("|")) {
+ pModel = pModel.substring(1).trim();
+ } else {
+ throw new SAXParseException("Expected '|' while parsing mixed content", pLocator);
+ }
+ int offset = pModel.indexOf('|');
+ String name;
+ if (offset == -1) {
+ name = pModel.trim();
+ pModel = "";
+ } else {
+ name = pModel.substring(0, offset).trim();
+ pModel = pModel.substring(offset);
+ }
+ if (elements.containsKey(name)) {
+ XsTLocalElement e = choice.createElement();
+ e.setRef(new XsQName(getTargetNamespace(), getLocalPart(name)));
+ } else {
+ throw new SAXParseException("Element " + pElement.getName()
+ + " references element " + name
+ + ", which is not declared",
+ pLocator);
+ }
+ }
+ return complexType;
+ }
+ }
+
+ /** Creates a new attribute.
+ */
+ protected void createAttribute(XsGAttrDecls pAttrDecls, DTDAttribute pAttribute)
+ throws SAXException {
+ XsTAttribute attr = pAttrDecls.createAttribute();
+ attr.setName(new XsNCName(getLocalPart(pAttribute.getName())));
+ String type = pAttribute.getType();
+ XsQName qName;
+ if ("CDATA".equals(type)) {
+ qName = XSString.getInstance().getName();
+ } else if ("ID".equals(type)) {
+ qName = XSID.getInstance().getName();
+ } else if ("IDREF".equals(type)) {
+ qName = XSIDREF.getInstance().getName();
+ } else if ("IDREFS".equals(type)) {
+ qName = XSIDREFs.getInstance().getName();
+ } else if ("ENTITY".equals(type)) {
+ qName = XSEntity.getInstance().getName();
+ } else if ("ENTITIES".equals(type)) {
+ qName = XSEntities.getInstance().getName();
+ } else if ("NMTOKEN".equals(type)) {
+ qName = XSNMToken.getInstance().getName();
+ } else if ("NMTOKENS".equals(type)) {
+ qName = XSNMTokens.getInstance().getName();
+ } else {
+ if (type.startsWith("NOTATION") &&
+ Character.isWhitespace(type.charAt("NOTATION".length()))) {
+ qName = XSNotation.getInstance().getName();
+ } else {
+ qName = XSNMToken.getInstance().getName();
+ }
+ XsTLocalSimpleType simpleType = attr.createSimpleType();
+ XsERestriction restriction = simpleType.createRestriction();
+ restriction.setBase(new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs"));
+ if (type.startsWith("(")) {
+ type = type.substring(1).trim();
+ } else {
+ throw new SAXParseException("The enumeration in the type of attribute "
+ + pAttribute.getName()
+ + " must begin with an '('.",
+ pAttribute.getLocator());
+ }
+ if (type.endsWith(")")) {
+ type = type.substring(0, type.length()-1).trim();
+ } else {
+ throw new SAXParseException("The enumeration in the type of attribute "
+ + pAttribute.getName()
+ + " must begin with an '('.",
+ pAttribute.getLocator());
+ }
+ StringTokenizer st = new StringTokenizer(type, "|");
+ if (!st.hasMoreTokens()) {
+ throw new SAXParseException("The enumeration in the type of attribute "
+ + pAttribute.getName()
+ + " contains no tokens.",
+ pAttribute.getLocator());
+ }
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken().trim();
+ if ("".equals(token)) {
+ throw new SAXParseException("The enumeration in the type of attribute "
+ + pAttribute.getName()
+ + " contains an empty token.",
+ pAttribute.getLocator());
+ }
+ XsEEnumeration enumeration = restriction.createEnumeration();
+ enumeration.setValue(token);
+ }
+ qName = null;
+ }
+ if (qName != null) {
+ attr.setType(new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs"));
+ }
+ }
+
+ private String getLocalPart(String pName) {
+ int offset = pName.indexOf(':');
+ if (offset >= 0) {
+ return pName.substring(offset+1);
+ } else {
+ return pName;
+ }
+ }
+
+ /** Creates an element named <code>pName</code> with the
+ * content model <code>pModel</code> and the attribute
+ * list <code>pAttrs</code> in the schema <code>pSchema</code>.
+ */
+ protected XsTTopLevelElement createElement(XsESchema pSchema, String pName,
+ String pModel,
+ DTDAttribute[] pAttributes,
+ Locator pLocator)
+ throws SAXException {
+ XsTTopLevelElement result = pSchema.createElement();
+ result.setName(new XsNCName(getLocalPart(pName)));
+ final XsGAttrDecls attrDecls;
+ if ("EMPTY".equals(pModel)) {
+ attrDecls = result.createComplexType();
+ } else if ("ANY".equals(pModel)) {
+ XsQName qName = XSAnyType.getInstance().getName();
+ qName = new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs");
+ if (pAttributes.length == 0) {
+ result.setType(qName);
+ attrDecls = null;
+ } else {
+ XsTComplexType complexType = result.createComplexType();
+ XsEComplexContent complexContent = complexType.createComplexContent();
+ XsTExtensionType extensionType = complexContent.createExtension();
+ extensionType.setBase(qName);
+ attrDecls = extensionType;
+ }
+ } else if (pModel.startsWith("(")) {
+ String pcData = pModel.substring(1).trim();
+ if (pcData.startsWith("#PCDATA")) {
+ attrDecls = parseMixed(result, pModel, pLocator, pAttributes.length > 0);
+ } else {
+ attrDecls = parseChildren(result, pModel, pLocator);
+ }
+ } else {
+ throw new SAXParseException("Invalid content model in element " + pName
+ + ", expected EMPTY|ANY|(...",
+ pLocator);
+ }
+ for (int i = 0; i < pAttributes.length; i++) {
+ createAttribute(attrDecls, pAttributes[i]);
+ }
+ return result;
+ }
+
+ /** Parses the given {@link org.xml.sax.InputSource} and
+ * converts it into an instance of
+ * {@link org.apache.ws.jaxme.xs.xml.XsESchema}.
+ */
+ protected void parse(XsESchema pSchema, InputSource pSource)
+ throws ParserConfigurationException, IOException, SAXException {
+ runXMLReader(pSource);
+ for (Iterator iter = elements.values().iterator(); iter.hasNext(); ) {
+ DTDElement element = (DTDElement) iter.next();
+ String name = element.getName();
+ String model = element.getModel();
+ DTDAttribute[] attrs = element.getAttributes();
+ if (attrs.length > 0 && model == null) {
+ throw new SAXParseException("The element " + name
+ + " is referred by attribute "
+ + attrs[0].getName()
+ + ", but never declared.",
+ attrs[0].getLocator());
+ }
+ createElement(pSchema, name, model, element.getAttributes(),
+ element.getLocator());
+ }
+ }
+
+ public XSSchema parse(InputSource pInputSource)
+ throws ParserConfigurationException, IOException, SAXException {
+ XsObjectFactoryImpl xsObjectFactory = new XsObjectFactoryImpl(){
+ public XSContext getContext() {
+ return getData();
+ }
+ };
+ context = new XSContextImpl();
+ context.setXSLogicalParser(this);
+ context.setXsObjectFactory(xsObjectFactory);
+ clearSyntaxSchemas();
+ XsESchema syntaxSchema = new XsESchemaImpl(context){
+ };
+ parse(syntaxSchema, pInputSource);
+ XSSchema schema = context.getXSObjectFactory().newXSSchema(context, syntaxSchema);
+ setSchema(schema);
+ parse(syntaxSchema, pInputSource.getSystemId());
+ schema.validate();
+ return schema;
+ }
+
+ /** Sets the created schemas target namespace.
+ */
+ public void setTargetNamespace(XsAnyURI pTargetNamespace) {
+ targetNamespace = pTargetNamespace;
+ }
+
+ /** Returns the created schemas target namespace.
+ */
+ public XsAnyURI getTargetNamespace() {
+ return targetNamespace;
+ }
+}
\ No newline at end of file
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/LoggingContentHandler.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/LoggingContentHandler.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/LoggingContentHandler.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/LoggingContentHandler.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,139 @@
+package org.apache.ws.jaxme.xs.util;
+
+import java.io.OutputStream;
+import java.io.Writer;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+
+
+/**
+ * A content handler, which may be used to log a stream of SAX events.
+ */
+public class LoggingContentHandler extends XMLFilterImpl implements LexicalHandler {
+ private final TransformerHandler th;
+
+ /**
+ * Creates a new instance, which is logging to the given
+ * output stream.
+ */
+ public LoggingContentHandler(OutputStream pStream) throws SAXException {
+ this(new StreamResult(pStream));
+ }
+
+ /**
+ * Creates a new instance, which is logging to the given writer.
+ * @param pResult
+ * @throws SAXException
+ */
+ public LoggingContentHandler(Writer pWriter) throws SAXException {
+ this(new StreamResult(pWriter));
+ }
+
+ private LoggingContentHandler(Result pResult) throws SAXException {
+ try {
+ th = ((SAXTransformerFactory) TransformerFactory.newInstance()).newTransformerHandler();
+ } catch (TransformerException e) {
+ throw new SAXException(e);
+ }
+ th.setResult(pResult);
+ }
+
+ public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
+ th.characters(arg0, arg1, arg2);
+ super.characters(arg0, arg1, arg2);
+ }
+
+ public void endDocument() throws SAXException {
+ th.endDocument();
+ super.endDocument();
+ }
+
+ public void endElement(String arg0, String arg1, String arg2) throws SAXException {
+ th.endElement(arg0, arg1, arg2);
+ super.endElement(arg0, arg1, arg2);
+ }
+
+ public void endPrefixMapping(String arg0) throws SAXException {
+ th.endPrefixMapping(arg0);
+ super.endPrefixMapping(arg0);
+ }
+
+ public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
+ th.ignorableWhitespace(arg0, arg1, arg2);
+ super.ignorableWhitespace(arg0, arg1, arg2);
+ }
+
+ public void notationDecl(String arg0, String arg1, String arg2) throws SAXException {
+ th.notationDecl(arg0, arg1, arg2);
+ super.notationDecl(arg0, arg1, arg2);
+ }
+
+ public void processingInstruction(String arg0, String arg1) throws SAXException {
+ th.processingInstruction(arg0, arg1);
+ super.processingInstruction(arg0, arg1);
+ }
+
+ public void skippedEntity(String arg0) throws SAXException {
+ th.skippedEntity(arg0);
+ super.skippedEntity(arg0);
+ }
+
+ public void startDocument() throws SAXException {
+ th.startDocument();
+ super.startDocument();
+ }
+
+ public void startElement(String arg0, String arg1, String arg2, Attributes arg3) throws SAXException {
+ th.startElement(arg0, arg1, arg2, arg3);
+ super.startElement(arg0, arg1, arg2, arg3);
+ }
+
+ public void startPrefixMapping(String arg0, String arg1) throws SAXException {
+ th.startPrefixMapping(arg0, arg1);
+ super.startPrefixMapping(arg0, arg1);
+ }
+
+ public void unparsedEntityDecl(String arg0, String arg1, String arg2, String arg3) throws SAXException {
+ th.unparsedEntityDecl(arg0, arg1, arg2, arg3);
+ super.unparsedEntityDecl(arg0, arg1, arg2, arg3);
+ }
+
+ public void comment(char[] arg0, int arg1, int arg2) throws SAXException {
+ th.comment(arg0, arg1, arg2);
+ }
+
+ public void endCDATA() throws SAXException {
+ th.endCDATA();
+ }
+
+ public void endDTD() throws SAXException {
+ th.endDTD();
+ }
+
+ public void endEntity(String arg0) throws SAXException {
+ th.endEntity(arg0);
+ }
+
+ public void startCDATA() throws SAXException {
+ th.startCDATA();
+ }
+
+ public void startDTD(String arg0, String arg1, String arg2) throws SAXException {
+ th.startDTD(arg0, arg1, arg2);
+ }
+
+ public void startEntity(String arg0) throws SAXException {
+ th.startEntity(arg0);
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateFormat.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateFormat.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateFormat.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateFormat.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.jaxme.xs.util;
+
+
+/** <p>An instance of {@link java.text.Format}, which may be used to parse
+ * and format <code>xs:dateTime</code> values.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsDateFormat extends XsDateTimeFormat {
+ /** Creates a new instance.
+ */
+ public XsDateFormat() {
+ super(true, false);
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateTimeFormat.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateTimeFormat.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateTimeFormat.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsDateTimeFormat.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,298 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.util;
+
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+
+/** <p>An instance of {@link java.text.Format}, which may be used
+ * to parse and format <code>xs:dateTime</code> values.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsDateTimeFormat extends Format {
+ final boolean parseDate;
+ final boolean parseTime;
+
+ XsDateTimeFormat(boolean pParseDate, boolean pParseTime) {
+ parseDate = pParseDate;
+ parseTime = pParseTime;
+ }
+
+ /** Creates a new instance.
+ */
+ public XsDateTimeFormat() {
+ this(true, true);
+ }
+
+ private int parseInt(String pString, int pOffset, StringBuffer pDigits) {
+ int length = pString.length();
+ pDigits.setLength(0);
+ while (pOffset < length) {
+ char c = pString.charAt(pOffset);
+ if (Character.isDigit(c)) {
+ pDigits.append(c);
+ ++pOffset;
+ } else {
+ break;
+ }
+ }
+ return pOffset;
+ }
+
+ public Object parseObject(String pString, ParsePosition pParsePosition) {
+ if (pString == null) {
+ throw new NullPointerException("The String argument must not be null.");
+ }
+ if (pParsePosition == null) {
+ throw new NullPointerException("The ParsePosition argument must not be null.");
+ }
+ int offset = pParsePosition.getIndex();
+ int length = pString.length();
+
+ boolean isMinus = false;
+ StringBuffer digits = new StringBuffer();
+ int year, month, mday;
+ if (parseDate) {
+ // Sign
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == '+') {
+ ++offset;
+ } else if (c == '-') {
+ ++offset;
+ isMinus = true;
+ }
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() < 4) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ year = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ month = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ mday = Integer.parseInt(digits.toString());
+
+ if (parseTime) {
+ if (offset < length && pString.charAt(offset) == 'T') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ }
+ } else {
+ year = month = mday = 0;
+ }
+
+ int hour, minute, second, millis;
+ if (parseTime) {
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ hour = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ minute = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ second = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '.') {
+ ++offset;
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() > 0) {
+ millis = Integer.parseInt(digits.toString());
+ if (millis > 999) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ for (int i = digits.length(); i < 3; i++) {
+ millis *= 10;
+ }
+ } else {
+ millis = 0;
+ }
+ } else {
+ millis = 0;
+ }
+ } else {
+ hour = minute = second = millis = 0;
+ }
+
+ digits.setLength(0);
+ digits.append("GMT");
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == 'Z') {
+ // Ignore UTC, it is the default
+ ++offset;
+ } else if (c == '+' || c == '-') {
+ digits.append(c);
+ ++offset;
+ for (int i = 0; i < 5; i++) {
+ if (offset >= length) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ c = pString.charAt(offset);
+ if ((i != 2 && Character.isDigit(c)) ||
+ (i == 2 && c == ':')) {
+ digits.append(c);
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ ++offset;
+ }
+ }
+ }
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString()));
+ cal.set(isMinus ? -year : year, parseDate ? month-1 : month, mday, hour, minute, second);
+ cal.set(Calendar.MILLISECOND, millis);
+ pParsePosition.setIndex(offset);
+ return cal;
+ }
+
+ private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
+ String s = Integer.toString(pNum);
+ for (int i = s.length(); i < pMinLen; i++) {
+ pBuffer.append('0');
+ }
+ pBuffer.append(s);
+ }
+
+ public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
+ if (pCalendar == null) {
+ throw new NullPointerException("The Calendar argument must not be null.");
+ }
+ if (pBuffer == null) {
+ throw new NullPointerException("The StringBuffer argument must not be null.");
+ }
+ if (pPos == null) {
+ throw new NullPointerException("The FieldPosition argument must not be null.");
+ }
+
+ Calendar cal = (Calendar) pCalendar;
+ if (parseDate) {
+ int year = cal.get(Calendar.YEAR);
+ if (year < 0) {
+ pBuffer.append('-');
+ year = -year;
+ }
+ append(pBuffer, year, 4);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.MONTH)+1, 2);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
+ if (parseTime) {
+ pBuffer.append('T');
+ }
+ }
+ if (parseTime) {
+ append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.MINUTE), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.SECOND), 2);
+ int millis = cal.get(Calendar.MILLISECOND);
+ if (millis > 0) {
+ pBuffer.append('.');
+ append(pBuffer, millis, 3);
+ }
+ }
+ TimeZone tz = cal.getTimeZone();
+ // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
+ int offset = cal.get(Calendar.ZONE_OFFSET);
+ if (tz.inDaylightTime(cal.getTime())) {
+ offset += cal.get(Calendar.DST_OFFSET);
+ }
+ if (offset == 0) {
+ pBuffer.append('Z');
+ } else {
+ if (offset < 0) {
+ pBuffer.append('-');
+ offset = -offset;
+ } else {
+ pBuffer.append('+');
+ }
+ int minutes = offset / (60*1000);
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ append(pBuffer, hours, 2);
+ pBuffer.append(':');
+ append(pBuffer, minutes, 2);
+ }
+ return pBuffer;
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsTimeFormat.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsTimeFormat.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsTimeFormat.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/XsTimeFormat.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.util;
+
+
+/** <p>An instance of {@link java.text.Format}, which may be used to parse
+ * and format <code>xs:dateTime</code> values.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsTimeFormat extends XsDateTimeFormat {
+ /** Creates a new instance.
+ */
+ public XsTimeFormat() {
+ super(false, true);
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/package.html
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/package.html?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/package.html (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/util/package.html Fri Nov 24 04:14:48 2006
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+ <head>
+ <title>
+Package Documentation for org.apache.ws.jaxme.xs.util Package
+ </title>
+</head>
+ <body bgcolor="white">
+ <p>
+Utility classes used by JaxMeXS.
+ </p>
+</body>
+</html>
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XmlLang.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XmlLang.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XmlLang.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XmlLang.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+/** <p>Implementation of <code>xml:lang</code>.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XmlLang {
+ private String lang;
+
+ public XmlLang(String pLang) {
+ if (pLang == null) {
+ throw new NullPointerException("An URI must not be null");
+ }
+ lang = pLang;
+ }
+
+ public boolean equals(Object o) {
+ return o != null && o instanceof XmlLang && lang.equals(((XmlLang) o).lang);
+ }
+
+ public int hashCode() {
+ return lang.hashCode();
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGDefRef.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGDefRef.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGDefRef.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGDefRef.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+import org.xml.sax.SAXException;
+
+/** <p>Interface of the attribute group <code>xs:defRef</code>,
+ * as specified by the following:
+ * <pre>
+ * <xs:attributeGroup name="defRef">
+ * <xs:annotation>
+ * <xs:documentation>
+ * for element, group and attributeGroup,
+ * which both define and reference
+ * </xs:documentation>
+ * </xs:annotation>
+ * <xs:attribute name="name" type="xs:NCName"/>
+ * <xs:attribute name="ref" type="xs:QName"/>
+ * </xs:attributeGroup>
+ * </pre></p>
+ * <p><em>Implementation note:</em> The 'name' and 'ref' attributes
+ * are mutually exclusive. This is checked by the 'validate' method.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public interface XsAGDefRef {
+ public void setName(XsNCName pName);
+ public XsNCName getName();
+ public void setRef(XsQName pRef);
+ public XsQName getRef();
+
+ /** <p>Validates whether the attribute groups constraints are met.</p>
+ */
+ public void validate() throws SAXException;
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGOccurs.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGOccurs.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGOccurs.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAGOccurs.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+import org.xml.sax.SAXException;
+
+/** <p>Interface of the attribute group <code>xs:occurs</code>,
+ * as specified by the following:
+ * <pre>
+ * <xs:attributeGroup name="occurs">
+ * <xs:annotation>
+ * <xs:documentation>
+ * for all particles
+ * </xs:documentation>
+ * </xs:annotation>
+ * <xs:attribute name="minOccurs" type="xs:nonNegativeInteger"
+ * use="optional" default="1"/>
+ * <xs:attribute name="maxOccurs" type="xs:allNNI"
+ * use="optional" default="1"/>
+ * </xs:attributeGroup>
+ * </pre></p>
+ * <p><em>Implementation note:</em> The implementation must ensure
+ * that either 'maxOccurs' is unbounded or 'minOccurs' <= 'maxOccurs'.
+ * This is checked by the <code>validate</code> method.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public interface XsAGOccurs {
+ /** <p>Either of 'unbounded' or a nonnegative integer value.</p>
+ */
+ public void setMaxOccurs(String pMaxOccurs);
+ /** <p>-1 for 'unbounded'</p>
+ */
+ public int getMaxOccurs();
+
+ public void setMinOccurs(int pMinOccurs);
+ public int getMinOccurs();
+
+ /** <p>Verifies whether the attribute group constraints are met.</p>
+ */
+ public void validate() throws SAXException;
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAnyURI.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAnyURI.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAnyURI.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsAnyURI.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+/** <p>Implementation of <code>xs:anyURI</code>.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsAnyURI {
+ private String uri;
+
+ public XsAnyURI(String pURI) {
+ if (pURI == null) {
+ throw new NullPointerException("An URI must not be null");
+ }
+ uri = pURI;
+ }
+
+ public boolean equals(Object o) {
+ return o != null && o instanceof XsAnyURI && uri.equals(((XsAnyURI) o).uri);
+ }
+
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ public String toString() {
+ return uri;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsBlockSet.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsBlockSet.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsBlockSet.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsBlockSet.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+import java.util.StringTokenizer;
+
+/** <p>Implementation of <code>xs:derivationset</code>.
+ * Follows this specification:
+ * <pre>
+ * <xs:simpleType name="blockSet">
+ * <xs:annotation>
+ * <xs:documentation>
+ * A utility type, not for public use
+ * </xs:documentation>
+ * <xs:documentation>
+ * #all or (possibly empty) subset of {substitution, extension,
+ * restriction}
+ * </xs:documentation>
+ * </xs:annotation>
+ * <xs:union>
+ * <xs:simpleType>
+ * <xs:restriction base="xs:token">
+ * <xs:enumeration value="#all"/>
+ * </xs:restriction>
+ * </xs:simpleType>
+ * <xs:simpleType>
+ * <xs:list>
+ * <xs:simpleType>
+ * <xs:restriction base="xs:derivationControl">
+ * <xs:enumeration value="extension"/>
+ * <xs:enumeration value="restriction"/>
+ * <xs:enumeration value="substitution"/>
+ * </xs:restriction>
+ * </xs:simpleType>
+ * </xs:list>
+ * </xs:simpleType>
+ * </xs:union>
+ * </xs:simpleType>
+ * </pre>
+ * </p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsBlockSet {
+ boolean extensionAllowed, restrictionAllowed, substitutionAllowed;
+
+ /** <p>Returns whether extension is allowed.</p>
+ */
+ public boolean isExtensionAllowed() {
+ return extensionAllowed;
+ }
+
+ /** <p>Sets whether extension is allowed.</p>
+ */
+ public void setExtensionAllowed(boolean pExtensionAllowed) {
+ extensionAllowed = pExtensionAllowed;
+ }
+
+ /** <p>Returns whether restriction is allowed.</p>
+ */
+ public boolean isRestrictionAllowed() {
+ return restrictionAllowed;
+ }
+
+ /** <p>Sets whether restriction is allowed.</p>
+ */
+ public void setRestrictionAllowed(boolean pRestrictionAllowed) {
+ restrictionAllowed = pRestrictionAllowed;
+ }
+
+ /** <p>Returns whether restriction is allowed.</p>
+ */
+ public boolean isSubstitutionAllowed() {
+ return substitutionAllowed;
+ }
+
+ /** <p>Sets whether restriction is allowed.</p>
+ */
+ public void setSubstitutionAllowed(boolean pSubstitutionAllowed) {
+ substitutionAllowed = pSubstitutionAllowed;
+ }
+
+ /** <p>Returns a <code>DerivationSet</code> matching the given
+ * value.</p>
+ */
+ public static XsBlockSet valueOf(String pValue) {
+ return new XsBlockSet(pValue);
+ }
+
+ /** <p>Creates a new DerivationSet with the given value.</p>
+ */
+ public XsBlockSet(String pValue) {
+ if ("#all".equals(pValue)) {
+ setExtensionAllowed(true);
+ setRestrictionAllowed(true);
+ setSubstitutionAllowed(true);
+ } else {
+ for (StringTokenizer st = new StringTokenizer(pValue, " "); st.hasMoreTokens(); ) {
+ String s = st.nextToken();
+ if ("extension".equals(s)) {
+ setExtensionAllowed(true);
+ } else if ("restriction".equals(s)) {
+ setRestrictionAllowed(true);
+ } else if ("substitution".equals(s)) {
+ setSubstitutionAllowed(true);
+ } else {
+ throw new IllegalArgumentException("Invalid block set value: " + pValue + "; the token " + s + " did not resolve to either of 'extension', 'restriction', or 'substitution'.");
+ }
+ }
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if (extensionAllowed) {
+ sb.append("extension");
+ }
+ if (restrictionAllowed) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append("restriction");
+ }
+ if (substitutionAllowed) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append("substitution");
+ }
+ return sb.toString();
+ }
+
+ public boolean equals(Object o) {
+ if (o == null || !(XsBlockSet.class.equals(o.getClass()))) {
+ return false;
+ }
+ XsBlockSet bs = (XsBlockSet) o;
+ return bs.extensionAllowed == extensionAllowed &&
+ bs.restrictionAllowed == restrictionAllowed &&
+ bs.substitutionAllowed == substitutionAllowed;
+ }
+
+ public int hashCode() {
+ int result = 0;
+ if (extensionAllowed) { result += 1; }
+ if (restrictionAllowed) { result += 2; }
+ if (substitutionAllowed) { result += 4; }
+ return result;
+ }
+}
Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsComplexContentType.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsComplexContentType.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsComplexContentType.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/XsComplexContentType.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2003, 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ */
+package org.apache.ws.jaxme.xs.xml;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XsComplexContentType {
+ private final String name;
+ private XsComplexContentType(String pName) {
+ name = pName;
+ }
+ public String toString() { return name; }
+ public boolean equals(Object o) {
+ return o != null && (o instanceof XsComplexContentType) && ((XsComplexContentType) o).name.equals(name);
+ }
+ public int hashCode() { return name.hashCode(); }
+
+ /** <p>For elements with 'complexContent' model: The content type empty.</p>
+ * @see org.apache.ws.jaxme.xs.XSComplexType#isEmpty()
+ * @see org.apache.ws.jaxme.xs.XSComplexType#getComplexContentType()
+ */
+ public static final XsComplexContentType EMPTY = new XsComplexContentType("empty");
+
+ /** <p>For elements with 'complexContent' model: The content type elementOnly.</p>
+ * @see org.apache.ws.jaxme.xs.XSComplexType#isElementOnly()
+ * @see org.apache.ws.jaxme.xs.XSComplexType#getComplexContentType()
+ */
+ public static final XsComplexContentType ELEMENT_ONLY = new XsComplexContentType("elementOnly");
+
+ /** <p>For elements with 'complexContent' model: The content type mixed.</p>
+ * @see org.apache.ws.jaxme.xs.XSComplexType#isMixed()
+ * @see org.apache.ws.jaxme.xs.XSComplexType#getComplexContentType()
+ */
+ public static final XsComplexContentType MIXED = new XsComplexContentType("mixed");
+
+ private static final XsComplexContentType[] instances = new XsComplexContentType[]{ EMPTY, ELEMENT_ONLY, MIXED };
+
+ public static XsComplexContentType valueOf(String pValue) {
+ for (int i = 0; i < instances.length; i++) {
+ if (instances[i].toString().equals(pValue)) {
+ return instances[i];
+ }
+ }
+ throw new IllegalArgumentException("Invalid complexContent type: " + pValue);
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org