From 5b838d686fce86ac96bb5ee7efcdfedc62922966 Mon Sep 17 00:00:00 2001
From: neeraj Utility class to contain basic XML values as constants. Private constructor to prevent instantiation. Namespace URI to use to represent that there is no Namespace. Defined by the Namespace specification to be "". Prefix to use to represent the default XML Namespace. Defined by the XML specification to be "". The official XML Namespace name URI. Defined by the XML specification to be
+ * " The official XML Namespace prefix. Defined by the XML specification to be " The official XML attribute used for specifying XML Namespace
+ * declarations, {@link #XMLNS_ATTRIBUTE
+ * XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI. Defined by the XML specification to be
+ * " The official XML attribute used for specifying XML Namespace
+ * declarations. It is NOT valid to use as a
+ * prefix. Defined by the XML specification to be
+ * " W3C XML Schema Namespace URI. Defined to be " W3C XML Schema Instance Namespace URI. Defined to be " W3C XPath Datatype Namespace URI. Defined to be " XML Document Type Declaration Namespace URI as an arbitrary value. Since not formally defined by any existing standard, arbitrarily define to be " RELAX NG Namespace URI. Defined to be " Feature for secure processing. Indicates a serious configuration error. Create a new Create a new Create a new Create a new Utility class to contain basic Datatype values as constants. Private constructor to prevent instantiation. Comparison result. Comparison result. Comparison result. Comparison result. A constant that represents the years field. A constant that represents the months field. A constant that represents the days field. A constant that represents the hours field. A constant that represents the minutes field. A constant that represents the seconds field. Unique id of the field. This value allows the {@link Duration} class to use switch
+ * statements to process fields. Construct a Get id of this Field. Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema 1.0 datatype Fully qualified name for W3C XML Schema datatype Fully qualified name for XQuery 1.0 and XPath 2.0 datatype Fully qualified name for XQuery 1.0 and XPath 2.0 datatype Factory that creates new {@link #newInstance()} is used to create a new Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3. Default value is Default implementation class name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3. Default value is Protected constructor to prevent instaniation outside of package. Use {@link #newInstance()} to create a Obtain a new instance of a The implementation resolution mechanisms are defined in this
+ * Obtain a new instance of a XML Schema Part 2: Datatypes, 3.2.6 duration, defines All six values are set and availabe from the created {@link Duration} The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. Obtain a new instance of a XML Schema Part 2: Datatypes, 3.2.6 duration, defines All six values are set by computing their values from the specified milliseconds
+ * and are availabe using the The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+ * {@link java.util.Calendar#YEAR} = 1970,
+ * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+ * {@link java.util.Calendar#DATE} = 1, etc.
+ * This is important as there are variations in the Gregorian Calendar,
+ * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+ * so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced. Obtain a new instance of a The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. A Obtain a new instance of a A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set. Create a The datatype All four values are set and availabe from the created {@link Duration} The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. Create a The datatype All four values are set by computing their values from the specified milliseconds
+ * and are availabe using the The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+ * {@link java.util.Calendar#YEAR} = 1970,
+ * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+ * {@link java.util.Calendar#DATE} = 1, etc.
+ * This is important as there are variations in the Gregorian Calendar,
+ * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+ * so the result of {@link Duration#getDays()} can be influenced. Any remaining milliseconds after determining the day, hour, minute and second are discarded. Create a The datatype The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. A Create a The datatype A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set. Create a The datatype Both values are set and availabe from the created {@link Duration} The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. Create a The datatype Both values are set by computing their values from the specified milliseconds
+ * and are availabe using the The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e.,
+ * {@link java.util.Calendar#YEAR} = 1970,
+ * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
+ * {@link java.util.Calendar#DATE} = 1, etc.
+ * This is important as there are variations in the Gregorian Calendar,
+ * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
+ * so the result of {@link Duration#getMonths()} can be influenced. Any remaining milliseconds after determining the year and month are discarded. Create a The XML Schema specification states that values can be of an arbitrary size.
+ * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
+ * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
+ * if implementation capacities are exceeded. A Create a A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set. Create a new instance of an All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null. Create a new XMLGregorianCalendar by parsing the String as a lexical representation. Parsing the lexical string representation is defined in
+ * XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
+ * Lexical Representation. The string representation may not have any leading and trailing whitespaces. The parsing is done field by field so that
+ * the following holds for any lexically correct String x: Except for the noted lexical/canonical representation mismatches
+ * listed in
+ * XML Schema 1.0 errata, Section 3.2.7.2. Create an *conversion loss of information. It is not possible to represent
+ * a To compute the return value's http://www.w3.org/XML/1998/namespace".xml".http://www.w3.org/2000/xmlns/".xmlns".http://www.w3.org/2001/XMLSchema".
+ *
+ * @see
+ * XML Schema Part 1:
+ * Structures, 2.6 Schema-Related Markup in Documents Being Validated
+ */
+ public static final String W3C_XML_SCHEMA_NS_URI =
+ "http://www.w3.org/2001/XMLSchema";
+
+ /**
+ * http://www.w3.org/2001/XMLSchema-instance".http://www.w3.org/2003/11/xpath-datatypes".http://www.w3.org/TR/REC-xml".
+ */
+ public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";
+
+ /**
+ * http://relaxng.org/ns/structure/1.0".
+ *
+ */
+ public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
+}
diff --git a/java/external/src/javax/xml/datatype/DatatypeConfigurationException.java b/java/external/src/javax/xml/datatype/DatatypeConfigurationException.java
new file mode 100644
index 0000000..f88fbef
--- /dev/null
+++ b/java/external/src/javax/xml/datatype/DatatypeConfigurationException.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.datatype;
+
+/**
+ * true instructs the implementation to process XML securely.
+ * This may set limits on XML constructs to avoid conditions such as denial of service attacks.
+ * false instructs the implementation to process XML acording the letter of the XML specifications
+ * ingoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.
+ * DatatypeConfigurationException with
+ * no specified detail mesage and cause.DatatypeConfigurationException with
+ * the specified detail message.DatatypeConfigurationException with
+ * the specified detail message and cause.null value is permitted, and indicates that the cause is nonexistent or unknown.
+ */
+
+ public DatatypeConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * DatatypeConfigurationException with
+ * the specified cause.null value is permitted, and indicates that the cause is nonexistent or unknown.
+ */
+
+ public DatatypeConfigurationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/java/external/src/javax/xml/datatype/DatatypeConstants.java b/java/external/src/javax/xml/datatype/DatatypeConstants.java
new file mode 100644
index 0000000..804e8e8
--- /dev/null
+++ b/java/external/src/javax/xml/datatype/DatatypeConstants.java
@@ -0,0 +1,267 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.datatype;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
+/**
+ * String representation of Field with specified values.String representation of Field
+ * @param id int representation of Field
+ */
+ private Field(final String str, final int id) {
+ this.str = str;
+ this.id = id;
+ }
+ /**
+ * Returns a field name in English. This method
+ * is intended to be used for debugging/diagnosis
+ * and not for display to end-users.
+ *
+ * @return
+ * a non-null valid String constant.
+ */
+ public String toString() { return str; }
+
+ /**
+ * dateTime.time.date.gYearMonth.gMonthDay.gYear.gMonth.gDay.duration.dayTimeDuration.yearMonthDuration.javax.xml.datatype Objects that map XML to/from Java Objects.DatatypeFactory.
+ * The following implementation resolution mechanisms are used in the following order:
+ *
+ *
+ * @author Joseph Fialli
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class DatatypeFactory {
+
+ /**
+ * javax.xml.datatype.DatatypeFactory",
+ * exists, a class with the name of the property's value is instantiated.
+ * Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
+ * Object.
+ * The Properties Object is then queried for the property as documented in the prior step
+ * and processed as documented in the prior step.
+ * META-INF/services/java.xml.datatype.DatatypeFactory.
+ * Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
+ * Class specified by
+ * {@link #DATATYPEFACTORY_IMPLEMENTATION_CLASS}, "javax.xml.datatype.DatatypeFactoryImpl".
+ * Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
+ * javax.xml.datatype.DatatypeFactory.org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.DatatypeFactory.DatatypeFactory.Class's documentation.DocumentBuilderFactory
+ *
+ * @throws DatatypeConfigurationException If the implementation is not
+ * available or cannot be instantiated.
+ */
+ public static DatatypeFactory newInstance()
+ throws DatatypeConfigurationException {
+
+ try {
+ return (DatatypeFactory) FactoryFinder.find(
+ /* The default property name according to the JAXP spec */
+ DATATYPEFACTORY_PROPERTY,
+ /* The fallback implementation class name */
+ DATATYPEFACTORY_IMPLEMENTATION_CLASS);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new DatatypeConfigurationException(e.getMessage(), e.getException());
+ }
+ }
+
+ /**
+ * Duration
+ * specifying the Duration as its string representation, "PnYnMnDTnHnMnS",
+ * as defined in XML Schema 1.0 section 3.2.6.1.duration as:
+ * duration represents a duration of time.
+ * The value space of duration is a six-dimensional space where the coordinates designate the
+ * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
+ * These components are ordered in their significance by their order of appearance i.e. as
+ * year, month, day, hour, minute, and second.
+ *
+ * String representation of a Duration.
+ *
+ * @return New Duration created from parsing the lexicalRepresentation.
+ *
+ * @throws IllegalArgumentException If lexicalRepresentation is not a valid representation of a Duration.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ * @throws NullPointerException if lexicalRepresentation is null.
+ */
+ public abstract Duration newDuration(final String lexicalRepresentation);
+
+ /**
+ * Duration
+ * specifying the Duration as milliseconds.duration as:
+ * duration represents a duration of time.
+ * The value space of duration is a six-dimensional space where the coordinates designate the
+ * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
+ * These components are ordered in their significance by their order of appearance i.e. as
+ * year, month, day, hour, minute, and second.
+ *
+ * get methods of the created {@link Duration}.
+ * The values conform to and are defined by:
+ *
+ *
+ * Duration representing durationInMilliSeconds.
+ */
+ public abstract Duration newDuration(final long durationInMilliSeconds);
+
+ /**
+ * Duration
+ * specifying the Duration as isPositive, years, months, days, hours, minutes, seconds.null value indicates that field isnot set.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param years of this Duration
+ * @param months of this Duration
+ * @param days of this Duration
+ * @param hours of this Duration
+ * @param minutes of this Duration
+ * @param seconds of this Duration
+ *
+ * @return New Duration created from the specified values.
+ *
+ * @throws IllegalArgumentException If values are not a valid representation of a Duration.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ */
+ public abstract Duration newDuration(
+ final boolean isPositive,
+ final BigInteger years,
+ final BigInteger months,
+ final BigInteger days,
+ final BigInteger hours,
+ final BigInteger minutes,
+ final BigDecimal seconds);
+
+ /**
+ * Duration
+ * specifying the Duration as isPositive, years, months, days, hours, minutes, seconds.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param years of this Duration
+ * @param months of this Duration
+ * @param days of this Duration
+ * @param hours of this Duration
+ * @param minutes of this Duration
+ * @param seconds of this Duration
+ *
+ * @return New Duration created from the specified values.
+ *
+ * @throws IllegalArgumentException If values are not a valid representation of a Duration.
+ *
+ * @see #newDuration(
+ * boolean isPositive,
+ * BigInteger years,
+ * BigInteger months,
+ * BigInteger days,
+ * BigInteger hours,
+ * BigInteger minutes,
+ * BigDecimal seconds)
+ */
+ public Duration newDuration(
+ final boolean isPositive,
+ final int years,
+ final int months,
+ final int days,
+ final int hours,
+ final int minutes,
+ final int seconds) {
+
+ // years may not be set
+ BigInteger realYears = (years != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) years) : null;
+
+ // months may not be set
+ BigInteger realMonths = (months != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) months) : null;
+
+ // days may not be set
+ BigInteger realDays = (days != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) days) : null;
+
+ // hours may not be set
+ BigInteger realHours = (hours != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) hours) : null;
+
+ // minutes may not be set
+ BigInteger realMinutes = (minutes != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) minutes) : null;
+
+ // seconds may not be set
+ BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long) seconds) : null;
+
+ return newDuration(
+ isPositive,
+ realYears,
+ realMonths,
+ realDays,
+ realHours,
+ realMinutes,
+ realSeconds
+ );
+ }
+
+ /**
+ * Duration of type xdt:dayTimeDuration by parsing its String representation,
+ * "PnDTnHnMnS",
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration.xdt:dayTimeDuration is a subtype of xs:duration
+ * whose lexical representation contains only day, hour, minute, and second components.
+ * This datatype resides in the namespace http://www.w3.org/2003/11/xpath-datatypes.Duration created using the specified lexicalRepresentation.
+ *
+ * @throws IllegalArgumentException If the given string does not conform to the aforementioned specification.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ * @throws NullPointerException If lexicalRepresentation is null.
+ */
+ public Duration newDurationDayTime(final String lexicalRepresentation) {
+
+ return newDuration(lexicalRepresentation);
+ }
+
+ /**
+ * Duration of type xdt:dayTimeDuration using the specified milliseconds as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration.xdt:dayTimeDuration is a subtype of xs:duration
+ * whose lexical representation contains only day, hour, minute, and second components.
+ * This datatype resides in the namespace http://www.w3.org/2003/11/xpath-datatypes.get methods of the created {@link Duration}.
+ * The values conform to and are defined by:
+ *
+ *
+ * Duration to create.
+ *
+ * @return New Duration created with the specified durationInMilliseconds.
+ *
+ * @see
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration
+ */
+ public Duration newDurationDayTime(final long durationInMilliseconds) {
+
+ return newDuration(durationInMilliseconds);
+ }
+
+ /**
+ * Duration of type xdt:dayTimeDuration using the specified
+ * day, hour, minute and second as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration.xdt:dayTimeDuration is a subtype of xs:duration
+ * whose lexical representation contains only day, hour, minute, and second components.
+ * This datatype resides in the namespace http://www.w3.org/2003/11/xpath-datatypes.null value indicates that field isnot set.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param day Day of Duration.
+ * @param hour Hour of Duration.
+ * @param minute Minute of Duration.
+ * @param second Second of Duration.
+ *
+ * @return New Duration created with the specified day, hour, minute
+ * and second.
+ *
+ * @throws IllegalArgumentException If any values would create an invalid Duration.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ */
+ public Duration newDurationDayTime(
+ final boolean isPositive,
+ final BigInteger day,
+ final BigInteger hour,
+ final BigInteger minute,
+ final BigInteger second) {
+
+ return newDuration(
+ isPositive,
+ null, // years
+ null, // months
+ day,
+ hour,
+ minute,
+ (second != null)? new BigDecimal(second):null
+ );
+ }
+
+ /**
+ * Duration of type xdt:dayTimeDuration using the specified
+ * day, hour, minute and second as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration.xdt:dayTimeDuration is a subtype of xs:duration
+ * whose lexical representation contains only day, hour, minute, and second components.
+ * This datatype resides in the namespace http://www.w3.org/2003/11/xpath-datatypes.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param day Day of Duration.
+ * @param hour Hour of Duration.
+ * @param minute Minute of Duration.
+ * @param second Second of Duration.
+ *
+ * @return New Duration created with the specified day, hour, minute
+ * and second.
+ *
+ * @throws IllegalArgumentException If any values would create an invalid Duration.
+ */
+ public Duration newDurationDayTime(
+ final boolean isPositive,
+ final int day,
+ final int hour,
+ final int minute,
+ final int second) {
+
+ return newDurationDayTime(
+ isPositive,
+ BigInteger.valueOf((long) day),
+ BigInteger.valueOf((long) hour),
+ BigInteger.valueOf((long) minute),
+ BigInteger.valueOf((long) second)
+ );
+ }
+
+ /**
+ * Duration of type xdt:yearMonthDuration by parsing its String representation,
+ * "PnYnM",
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.xdt:yearMonthDuration is a subtype of xs:duration
+ * whose lexical representation contains only year and month components.
+ * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.Duration created using the specified lexicalRepresentation.
+ *
+ * @throws IllegalArgumentException If the lexicalRepresentation does not conform to the specification.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ * @throws NullPointerException If lexicalRepresentation is null.
+ */
+ public Duration newDurationYearMonth(final String lexicalRepresentation) {
+
+ return newDuration(lexicalRepresentation);
+ }
+
+ /**
+ * Duration of type xdt:yearMonthDuration using the specified milliseconds as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.xdt:yearMonthDuration is a subtype of xs:duration
+ * whose lexical representation contains only year and month components.
+ * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.get methods of the created {@link Duration}.
+ * The values conform to and are defined by:
+ *
+ *
+ * Duration to create.
+ *
+ * @return New Duration created using the specified durationInMilliseconds.
+ */
+ public Duration newDurationYearMonth(final long durationInMilliseconds) {
+
+ return newDuration(durationInMilliseconds);
+ }
+
+ /**
+ * Duration of type xdt:yearMonthDuration using the specified
+ * year and month as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.null value indicates that field isnot set.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param year Year of Duration.
+ * @param month Month of Duration.
+ *
+ * @return New Duration created using the specified year and month.
+ *
+ * @throws IllegalArgumentException If any values would create an invalid Duration.
+ * @throws UnsupportedOperationException If implementation cannot support requested values.
+ */
+ public Duration newDurationYearMonth(
+ final boolean isPositive,
+ final BigInteger year,
+ final BigInteger month) {
+
+ return newDuration(
+ isPositive,
+ year,
+ month,
+ null, // days
+ null, // hours
+ null, // minutes
+ null // seconds
+ );
+ }
+
+ /**
+ * Duration of type xdt:yearMonthDuration using the specified
+ * year and month as defined in
+ *
+ * XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.false to create a negative duration. When the length
+ * of the duration is zero, this parameter will be ignored.
+ * @param year Year of Duration.
+ * @param month Month of Duration.
+ *
+ * @return New Duration created using the specified year and month.
+ *
+ * @throws IllegalArgumentException If any values would create an invalid Duration.
+ */
+ public Duration newDurationYearMonth(
+ final boolean isPositive,
+ final int year,
+ final int month) {
+
+ return newDurationYearMonth(
+ isPositive,
+ BigInteger.valueOf((long) year),
+ BigInteger.valueOf((long) month));
+ }
+
+ /**
+ * XMLGregorianCalendar.XMLGregorianCalendar with all date/time datatype fields set to
+ * {@link DatatypeConstants#FIELD_UNDEFINED} or null.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar();
+
+ /**
+ *
+ * newXMLGregorianCalendar(x).toXMLFormat().equals(x)
+ *
+ * XMLGregorianCalendar created from the lexicalRepresentation.
+ *
+ * @throws IllegalArgumentException If the lexicalRepresentation is not a valid XMLGregorianCalendar.
+ * @throws NullPointerException If lexicalRepresentation is null.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
+
+ /**
+ * XMLGregorianCalendar from a {@link GregorianCalendar}.
+ *
+ *
+ *
+ *
+ *
+ * Field by Field Conversion from
+ * {@link GregorianCalendar} to an {@link XMLGregorianCalendar}
+ *
+ *
+ *
+ *
+ *
+ *
+ * java.util.GregorianCalendar field
+ * javax.xml.datatype.XMLGregorianCalendar field
+ *
+ *
+ * ERA == GregorianCalendar.BC ? -YEAR : YEAR{@link XMLGregorianCalendar#setYear(int year)}
+ *
+ *
+ *
+ * MONTH + 1{@link XMLGregorianCalendar#setMonth(int month)}
+ *
+ *
+ *
+ * DAY_OF_MONTH{@link XMLGregorianCalendar#setDay(int day)}
+ *
+ *
+ *
+ * HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}
+ *
+ *
+ *
+ *
+ *
+ * (ZONE_OFFSET + DST_OFFSET) / (60*1000)
+ * (in minutes)
+ * {@link XMLGregorianCalendar#setTimezone(int offset)}*
+ *
+ * java.util.GregorianCalendar daylight savings timezone id in the
+ * XML Schema 1.0 date/time datatype representation.TimeZone field,
+ *
+ *
this.getTimezone() != FIELD_UNDEFINED,
+ * create a java.util.TimeZone with a custom timezone id
+ * using the this.getTimezone().GregorianCalendar default timezone value
+ * for the host is defined as specified by
+ * java.util.TimeZone.getDefault().
java.util.GregorianCalendar used to create XMLGregorianCalendar
+ *
+ * @return XMLGregorianCalendar created from java.util.GregorianCalendar
+ *
+ * @throws NullPointerException If cal is null.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
+
+ /**
+ * Constructor allowing for complete value spaces allowed by
+ * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
+ * builtin datatypes. Note that year parameter supports
+ * arbitrarily large numbers and fractionalSecond has infinite
+ * precision.
A null value indicates that field isnot set.
XMLGregorianCalendar to be created.
+ * @param month of XMLGregorianCalendar to be created.
+ * @param day of XMLGregorianCalendar to be created.
+ * @param hour of XMLGregorianCalendar to be created.
+ * @param minute of XMLGregorianCalendar to be created.
+ * @param second of XMLGregorianCalendar to be created.
+ * @param fractionalSecond of XMLGregorianCalendar to be created.
+ * @param timezone of XMLGregorianCalendar to be created.
+ *
+ * @return XMLGregorianCalendar created from specified values.
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(
+ final BigInteger year,
+ final int month,
+ final int day,
+ final int hour,
+ final int minute,
+ final int second,
+ final BigDecimal fractionalSecond,
+ final int timezone);
+
+ /**
+ * Constructor of value spaces that a
+ * java.util.GregorianCalendar instance would need to convert to an
+ * XMLGregorianCalendar instance.
XMLGregorianCalendar eon and
+ * fractionalSecond are set to null
A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set.
+ * + * @param year ofXMLGregorianCalendar to be created.
+ * @param month of XMLGregorianCalendar to be created.
+ * @param day of XMLGregorianCalendar to be created.
+ * @param hour of XMLGregorianCalendar to be created.
+ * @param minute of XMLGregorianCalendar to be created.
+ * @param second of XMLGregorianCalendar to be created.
+ * @param millisecond of XMLGregorianCalendar to be created.
+ * @param timezone of XMLGregorianCalendar to be created.
+ *
+ * @return XMLGregorianCalendar created from specified values.
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendar(
+ final int year,
+ final int month,
+ final int day,
+ final int hour,
+ final int minute,
+ final int second,
+ final int millisecond,
+ final int timezone) {
+
+ // year may be undefined
+ BigInteger realYear = (year != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) year) : null;
+
+ // millisecond may be undefined
+ // millisecond must be >= 0 millisecond <= 1000
+ BigDecimal realMillisecond = null; // undefined value
+ if (millisecond != DatatypeConstants.FIELD_UNDEFINED) {
+ if (millisecond < 0 || millisecond > 1000) {
+ throw new IllegalArgumentException(
+ "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar("
+ + "int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)"
+ + "with invalid millisecond: " + millisecond
+ );
+ }
+
+ realMillisecond = BigDecimal.valueOf((long) millisecond).movePointLeft(3);
+ }
+
+ return newXMLGregorianCalendar(
+ realYear,
+ month,
+ day,
+ hour,
+ minute,
+ second,
+ realMillisecond,
+ timezone
+ );
+ }
+
+ /**
+ * Create a Java representation of XML Schema builtin datatype date or g*.
For example, an instance of gYear can be created invoking this factory
+ * with month and day parameters set to
+ * {@link DatatypeConstants#FIELD_UNDEFINED}.
A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set.
+ * + * @param year ofXMLGregorianCalendar to be created.
+ * @param month of XMLGregorianCalendar to be created.
+ * @param day of XMLGregorianCalendar to be created.
+ * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+ *
+ * @return XMLGregorianCalendar created from parameter values.
+ *
+ * @see DatatypeConstants#FIELD_UNDEFINED
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarDate(
+ final int year,
+ final int month,
+ final int day,
+ final int timezone) {
+
+ return newXMLGregorianCalendar(
+ year,
+ month,
+ day,
+ DatatypeConstants.FIELD_UNDEFINED, // hour
+ DatatypeConstants.FIELD_UNDEFINED, // minute
+ DatatypeConstants.FIELD_UNDEFINED, // second
+ DatatypeConstants.FIELD_UNDEFINED, // millisecond
+ timezone);
+ }
+
+ /**
+ * Create a Java instance of XML Schema builtin datatype time.
A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set.
+ * + * @param hours number of hours + * @param minutes number of minutes + * @param seconds number of seconds + * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. + * + * @returnXMLGregorianCalendar created from parameter values.
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ *
+ * @see DatatypeConstants#FIELD_UNDEFINED
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(
+ final int hours,
+ final int minutes,
+ final int seconds,
+ final int timezone) {
+
+ return newXMLGregorianCalendar(
+ DatatypeConstants.FIELD_UNDEFINED, // Year
+ DatatypeConstants.FIELD_UNDEFINED, // Month
+ DatatypeConstants.FIELD_UNDEFINED, // Day
+ hours,
+ minutes,
+ seconds,
+ DatatypeConstants.FIELD_UNDEFINED, //Millisecond
+ timezone);
+ }
+
+ /**
+ * Create a Java instance of XML Schema builtin datatype time.
+ * + *A null value indicates that field isnot set.
A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set.
+ * + * @param hours number of hours + * @param minutes number of minutes + * @param seconds number of seconds + * @param fractionalSecond value ofnull indicates that this optional field is not set.
+ * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
+ *
+ * @return XMLGregorianCalendar created from parameter values.
+ *
+ * @see DatatypeConstants#FIELD_UNDEFINED
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(
+ final int hours,
+ final int minutes,
+ final int seconds,
+ final BigDecimal fractionalSecond,
+ final int timezone) {
+
+ return newXMLGregorianCalendar(
+ null, // year
+ DatatypeConstants.FIELD_UNDEFINED, // month
+ DatatypeConstants.FIELD_UNDEFINED, // day
+ hours,
+ minutes,
+ seconds,
+ fractionalSecond,
+ timezone);
+ }
+
+ /**
+ * Create a Java instance of XML Schema builtin datatype time.
+ * + *A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field isnot set.
+ * + * @param hours number of hours + * @param minutes number of minutes + * @param seconds number of seconds + * @param milliseconds number of milliseconds + * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. + * + * @returnXMLGregorianCalendar created from parameter values.
+ *
+ * @see DatatypeConstants#FIELD_UNDEFINED
+ *
+ * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
+ * as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
+ * or if the composite values constitute an invalid XMLGregorianCalendar instance
+ * as determined by {@link XMLGregorianCalendar#isValid()}.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(
+ final int hours,
+ final int minutes,
+ final int seconds,
+ final int milliseconds,
+ final int timezone) {
+
+ // millisecond may be undefined
+ // millisecond must be >= 0 millisecond <= 1000
+ BigDecimal realMilliseconds = null; // undefined value
+ if (milliseconds != DatatypeConstants.FIELD_UNDEFINED) {
+ if (milliseconds < 0 || milliseconds > 1000) {
+ throw new IllegalArgumentException(
+ "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendarTime("
+ + "int hours, int minutes, int seconds, int milliseconds, int timezone)"
+ + "with invalid milliseconds: " + milliseconds
+ );
+ }
+
+ realMilliseconds = BigDecimal.valueOf((long) milliseconds).movePointLeft(3);
+ }
+
+ return newXMLGregorianCalendarTime(
+ hours,
+ minutes,
+ seconds,
+ realMilliseconds,
+ timezone
+ );
+ }
+}
diff --git a/java/external/src/javax/xml/datatype/Duration.java b/java/external/src/javax/xml/datatype/Duration.java
new file mode 100644
index 0000000..97eed2c
--- /dev/null
+++ b/java/external/src/javax/xml/datatype/Duration.java
@@ -0,0 +1,974 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.datatype;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Immutable representation of a time span as defined in + * the W3C XML Schema 1.0 specification.
+ * + *A Duration object represents a period of Gregorian time, + * which consists of six fields (years, months, days, hours, + * minutes, and seconds) plus a sign (+/-) field.
+ * + *The first five fields have non-negative (>=0) integers or null + * (which represents that the field is not set), + * and the seconds field has a non-negative decimal or null. + * A negative sign indicates a negative duration.
+ * + *This class provides a number of methods that make it easy + * to use for the duration datatype of XML Schema 1.0 with + * the errata.
+ * + *Duration objects only have partial order, where two values A and B + * maybe either:
+ *For example, 30 days cannot be meaningfully compared to one month. + * The {@link #compare(Duration duration)} method implements this + * relationship.
+ * + *See the {@link #isLongerThan(Duration)} method for details about
+ * the order relationship among Duration objects.
This class provides a set of basic arithmetic operations, such + * as addition, subtraction and multiplication. + * Because durations don't have total order, an operation could + * fail for some combinations of operations. For example, you cannot + * subtract 15 days from 1 month. See the javadoc of those methods + * for detailed conditions where this could happen.
+ * + *Also, division of a duration by a number is not provided because
+ * the Duration class can only deal with finite precision
+ * decimal numbers. For example, one cannot represent 1 sec divided by 3.
However, you could substitute a division by 3 with multiplying + * by numbers such as 0.3 or 0.333.
+ * + *
+ * Because some operations of Duration rely on {@link Calendar}
+ * even though {@link Duration} can hold very large or very small values,
+ * some of the methods may not work correctly on such Durations.
+ * The impacted methods document their dependency on {@link Calendar}.
+ *
+ *
+ * @author Joseph Fialli
+ * @author Kohsuke Kawaguchi
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @see XMLGregorianCalendar#add(Duration)
+ * @since 1.5
+ */
+public abstract class Duration {
+
+ /**
+ *
Debugging true or false.
Return the name of the XML Schema date/time type that this instance
+ * maps to. Type is computed based on fields that are set,
+ * i.e. {@link #isSet(DatatypeConstants.Field field)} == true.
|
+ * Required fields for XML Schema 1.0 Date/Time Datatypes. + * (timezone is optional for all date/time datatypes) + * |
+ * ||||||
|---|---|---|---|---|---|---|
| Datatype | + *year | + *month | + *day | + *hour | + *minute | + *second | + *
| {@link DatatypeConstants#DURATION} | + *X | + *X | + *X | + *X | + *X | + *X | + *
| {@link DatatypeConstants#DURATION_DAYTIME} | + *+ * | + * | X | + *X | + *X | + *X | + *
| {@link DatatypeConstants#DURATION_YEARMONTH} | + *X | + *X | + *+ * | + * | + * | + * |
Get the years value of this Duration as an int or 0 if not present.
getYears() is a convenience method for
+ * {@link #getField(DatatypeConstants.Field field) getField(DatatypeConstants.YEARS)}.
As the return value is an int, an incorrect value will be returned for Durations
+ * with years that go beyond the range of an int.
+ * Use {@link #getField(DatatypeConstants.Field field) getField(DatatypeConstants.YEARS)} to avoid possible loss of precision.
int, else return 0.
+ */
+ public int getYears() {
+ return getField(DatatypeConstants.YEARS).intValue();
+ }
+
+ /**
+ * Obtains the value of the MONTHS field as an integer value,
+ * or 0 if not present.
+ *
+ * This method works just like {@link #getYears()} except
+ * that this method works on the MONTHS field.
+ *
+ * @return Months of this Duration.
+ */
+ public int getMonths() {
+ return getField(DatatypeConstants.MONTHS).intValue();
+ }
+
+ /**
+ * Obtains the value of the DAYS field as an integer value,
+ * or 0 if not present.
+ *
+ * This method works just like {@link #getYears()} except
+ * that this method works on the DAYS field.
+ *
+ * @return Days of this Duration.
+ */
+ public int getDays() {
+ return getField(DatatypeConstants.DAYS).intValue();
+ }
+
+ /**
+ * Obtains the value of the HOURS field as an integer value,
+ * or 0 if not present.
+ *
+ * This method works just like {@link #getYears()} except
+ * that this method works on the HOURS field.
+ *
+ * @return Hours of this Duration.
+ *
+ */
+ public int getHours() {
+ return getField(DatatypeConstants.HOURS).intValue();
+ }
+
+ /**
+ * Obtains the value of the MINUTES field as an integer value,
+ * or 0 if not present.
+ *
+ * This method works just like {@link #getYears()} except
+ * that this method works on the MINUTES field.
+ *
+ * @return Minutes of this Duration.
+ *
+ */
+ public int getMinutes() {
+ return getField(DatatypeConstants.MINUTES).intValue();
+ }
+
+ /**
+ * Obtains the value of the SECONDS field as an integer value,
+ * or 0 if not present.
+ *
+ * This method works just like {@link #getYears()} except
+ * that this method works on the SECONDS field.
+ *
+ * @return seconds in the integer value. The fraction of seconds
+ * will be discarded (for example, if the actual value is 2.5,
+ * this method returns 2)
+ */
+ public int getSeconds() {
+ return getField(DatatypeConstants.SECONDS).intValue();
+ }
+
+ /**
+ * Returns the length of the duration in milli-seconds.
+ * + *If the seconds field carries more digits than milli-second order,
+ * those will be simply discarded (or in other words, rounded to zero.)
+ * For example, for any Calendar value x,
+ *+ * + *new Duration("PT10.00099S").getTimeInMills(x) == 10000. + *new Duration("-PT10.00099S").getTimeInMills(x) == -10000. + *
+ * Note that this method uses the {@link #addTo(Calendar)} method,
+ * which may work incorrectly with Duration objects with
+ * very large values in its fields. See the {@link #addTo(Calendar)}
+ * method for details.
+ *
+ * @param startInstant
+ * The length of a month/year varies. The startInstant is
+ * used to disambiguate this variance. Specifically, this method
+ * returns the difference between startInstant and
+ * startInstant+duration
+ *
+ * @return milliseconds between startInstant and
+ * startInstant plus this Duration
+ *
+ * @throws NullPointerException if startInstant parameter
+ * is null.
+ *
+ */
+ public long getTimeInMillis(final Calendar startInstant) {
+ Calendar cal = (Calendar) startInstant.clone();
+ addTo(cal);
+ return getCalendarTimeInMillis(cal)
+ - getCalendarTimeInMillis(startInstant);
+ }
+
+ /**
+ *
Returns the length of the duration in milli-seconds.
+ * + *If the seconds field carries more digits than milli-second order,
+ * those will be simply discarded (or in other words, rounded to zero.)
+ * For example, for any Date value x,
+ *+ * + *new Duration("PT10.00099S").getTimeInMills(x) == 10000. + *new Duration("-PT10.00099S").getTimeInMills(x) == -10000. + *
+ * Note that this method uses the {@link #addTo(Date)} method,
+ * which may work incorrectly with Duration objects with
+ * very large values in its fields. See the {@link #addTo(Date)}
+ * method for details.
+ *
+ * @param startInstant
+ * The length of a month/year varies. The startInstant is
+ * used to disambiguate this variance. Specifically, this method
+ * returns the difference between startInstant and
+ * startInstant+duration.
+ *
+ * @throws NullPointerException
+ * If the startInstant parameter is null.
+ *
+ * @return milliseconds between startInstant and
+ * startInstant plus this Duration
+ *
+ * @see #getTimeInMillis(Calendar)
+ */
+ public long getTimeInMillis(final Date startInstant) {
+ Calendar cal = new GregorianCalendar();
+ cal.setTime(startInstant);
+ this.addTo(cal);
+ return getCalendarTimeInMillis(cal) - startInstant.getTime();
+ }
+
+ /**
+ * Gets the value of a field.
+ *
+ * Fields of a duration object may contain arbitrary large value.
+ * Therefore this method is designed to return a {@link Number} object.
+ *
+ * In case of YEARS, MONTHS, DAYS, HOURS, and MINUTES, the returned
+ * number will be a non-negative integer. In case of seconds,
+ * the returned number may be a non-negative decimal value.
+ *
+ * @param field
+ * one of the six Field constants (YEARS,MONTHS,DAYS,HOURS,
+ * MINUTES, or SECONDS.)
+ * @return
+ * If the specified field is present, this method returns
+ * a non-null non-negative {@link Number} object that
+ * represents its value. If it is not present, return null.
+ * For YEARS, MONTHS, DAYS, HOURS, and MINUTES, this method
+ * returns a {@link java.math.BigInteger} object. For SECONDS, this
+ * method returns a {@link java.math.BigDecimal}.
+ *
+ * @throws NullPointerException If the field is null.
+ */
+ public abstract Number getField(final DatatypeConstants.Field field);
+
+ /**
+ * Checks if a field is set.
+ *
+ * A field of a duration object may or may not be present.
+ * This method can be used to test if a field is present.
+ *
+ * @param field
+ * one of the six Field constants (YEARS,MONTHS,DAYS,HOURS,
+ * MINUTES, or SECONDS.)
+ * @return
+ * true if the field is present. false if not.
+ *
+ * @throws NullPointerException
+ * If the field parameter is null.
+ */
+ public abstract boolean isSet(final DatatypeConstants.Field field);
+
+ /**
+ *
Computes a new duration whose value is this+rhs.
For example,
+ *+ * "1 day" + "-3 days" = "-2 days" + * "1 year" + "1 day" = "1 year and 1 day" + * "-(1 hour,50 minutes)" + "-20 minutes" = "-(1 hours,70 minutes)" + * "15 hours" + "-3 days" = "-(2 days,9 hours)" + * "1 year" + "-1 day" = IllegalStateException + *+ * + *
Since there's no way to meaningfully subtract 1 day from 1 month, + * there are cases where the operation fails in + * {@link IllegalStateException}.
+ * + *+ * Formally, the computation is defined as follows.
+ *
+ * Firstly, we can assume that two Durations to be added
+ * are both positive without losing generality (i.e.,
+ * (-X)+Y=Y-X, X+(-Y)=X-Y,
+ * (-X)+(-Y)=-(X+Y))
+ *
+ *
+ * Addition of two positive Durations are simply defined as
+ * field by field addition where missing fields are treated as 0.
+ *
+ * A field of the resulting Duration will be unset if and
+ * only if respective fields of two input Durations are unset.
+ *
+ * Note that lhs.add(rhs) will be always successful if
+ * lhs.signum()*rhs.signum()!=-1 or both of them are
+ * normalized.
Duration to add to this Duration
+ *
+ * @return
+ * non-null valid Duration object.
+ *
+ * @throws NullPointerException
+ * If the rhs parameter is null.
+ * @throws IllegalStateException
+ * If two durations cannot be meaningfully added. For
+ * example, adding negative one day to one month causes
+ * this exception.
+ *
+ *
+ * @see #subtract(Duration)
+ */
+ public abstract Duration add(final Duration rhs);
+
+ /**
+ * Adds this duration to a {@link Calendar} object.
+ *
+ * + * Calls {@link java.util.Calendar#add(int,int)} in the + * order of YEARS, MONTHS, DAYS, HOURS, MINUTES, SECONDS, and MILLISECONDS + * if those fields are present. Because the {@link Calendar} class + * uses int to hold values, there are cases where this method + * won't work correctly (for example if values of fields + * exceed the range of int.) + *
+ * + *+ * Also, since this duration class is a Gregorian duration, this + * method will not work correctly if the given {@link Calendar} + * object is based on some other calendar systems. + *
+ * + *
+ * Any fractional parts of this Duration object
+ * beyond milliseconds will be simply ignored. For example, if
+ * this duration is "P1.23456S", then 1 is added to SECONDS,
+ * 234 is added to MILLISECONDS, and the rest will be unused.
+ *
+ * Note that because {@link Calendar#add(int, int)} is using
+ * int, Duration with values beyond the
+ * range of int in its fields
+ * will cause overflow/underflow to the given {@link Calendar}.
+ * {@link XMLGregorianCalendar#add(Duration)} provides the same
+ * basic operation as this method while avoiding
+ * the overflow/underflow issues.
+ *
+ * @param calendar
+ * A calendar object whose value will be modified.
+ * @throws NullPointerException
+ * if the calendar parameter is null.
+ */
+ public abstract void addTo(Calendar calendar);
+
+ /**
+ * Adds this duration to a {@link Date} object.
+ *
+ *
+ * The given date is first converted into + * a {@link java.util.GregorianCalendar}, then the duration + * is added exactly like the {@link #addTo(Calendar)} method. + * + *
+ * The updated time instant is then converted back into a + * {@link Date} object and used to update the given {@link Date} object. + * + *
+ * This somewhat redundant computation is necessary to unambiguously + * determine the duration of months and years. + * + * @param date + * A date object whose value will be modified. + * @throws NullPointerException + * if the date parameter is null. + */ + public void addTo(Date date) { + + // check data parameter + if (date == null) { + throw new NullPointerException( + "Cannot call " + + this.getClass().getName() + + "#addTo(Date date) with date == null." + ); + } + + Calendar cal = new GregorianCalendar(); + cal.setTime(date); + this.addTo(cal); + date.setTime(getCalendarTimeInMillis(cal)); + } + + /** + *
Computes a new duration whose value is this-rhs.
For example:
+ *+ * "1 day" - "-3 days" = "4 days" + * "1 year" - "1 day" = IllegalStateException + * "-(1 hour,50 minutes)" - "-20 minutes" = "-(1hours,30 minutes)" + * "15 hours" - "-3 days" = "3 days and 15 hours" + * "1 year" - "-1 day" = "1 year and 1 day" + *+ * + *
Since there's no way to meaningfully subtract 1 day from 1 month, + * there are cases where the operation fails in {@link IllegalStateException}.
+ * + *Formally the computation is defined as follows.
+ * First, we can assume that two Durations are both positive
+ * without losing generality. (i.e.,
+ * (-X)-Y=-(X+Y), X-(-Y)=X+Y,
+ * (-X)-(-Y)=-(X-Y))
Then two durations are subtracted field by field. + * If the sign of any non-zero field F is different from + * the sign of the most significant field, + * 1 (if F is negative) or -1 (otherwise) + * will be borrowed from the next bigger unit of F.
+ * + *This process is repeated until all the non-zero fields have + * the same sign.
+ * + *If a borrow occurs in the days field (in other words, if + * the computation needs to borrow 1 or -1 month to compensate + * days), then the computation fails by throwing an + * {@link IllegalStateException}.
+ * + * @param rhsDuration to subtract from this Duration.
+ *
+ * @return New Duration created from subtracting rhs from this Duration.
+ *
+ * @throws IllegalStateException
+ * If two durations cannot be meaningfully subtracted. For
+ * example, subtracting one day from one month causes
+ * this exception.
+ *
+ * @throws NullPointerException
+ * If the rhs parameter is null.
+ *
+ * @see #add(Duration)
+ */
+ public Duration subtract(final Duration rhs) {
+ return add(rhs.negate());
+ }
+
+ /**
+ * Computes a new duration whose value is factor times
+ * longer than the value of this duration.
This method is provided for the convenience. + * It is functionally equivalent to the following code:
+ *+ * multiply(new BigDecimal(String.valueOf(factor))) + *+ * + * @param factor Factor times longer of new
Duration to create.
+ *
+ * @return New Duration that is factortimes longer than this Duration.
+ *
+ * @see #multiply(BigDecimal)
+ */
+ public Duration multiply(int factor) {
+ return multiply(new BigDecimal(String.valueOf(factor)));
+ }
+
+ /**
+ * Computes a new duration whose value is factor times
+ * longer than the value of this duration.
+ *
+ * + * For example, + *
+ * "P1M" (1 month) * "12" = "P12M" (12 months) + * "PT1M" (1 min) * "0.3" = "PT18S" (18 seconds) + * "P1M" (1 month) * "1.5" = IllegalStateException + *+ * + *
+ * Since the Duration class is immutable, this method
+ * doesn't change the value of this object. It simply computes
+ * a new Duration object and returns it.
+ *
+ *
+ * The operation will be performed field by field with the precision + * of {@link BigDecimal}. Since all the fields except seconds are + * restricted to hold integers, + * any fraction produced by the computation will be + * carried down toward the next lower unit. For example, + * if you multiply "P1D" (1 day) with "0.5", then it will be 0.5 day, + * which will be carried down to "PT12H" (12 hours). + * When fractions of month cannot be meaningfully carried down + * to days, or year to months, this will cause an + * {@link IllegalStateException} to be thrown. + * For example if you multiple one month by 0.5.
+ * + *
+ * To avoid {@link IllegalStateException}, use
+ * the {@link #normalizeWith(Calendar)} method to remove the years
+ * and months fields.
+ *
+ * @param factor to multiply by
+ *
+ * @return
+ * returns a non-null valid Duration object
+ *
+ * @throws IllegalStateException if operation produces fraction in
+ * the months field.
+ *
+ * @throws NullPointerException if the factor parameter is
+ * null.
+ *
+ */
+ public abstract Duration multiply(final BigDecimal factor);
+
+ /**
+ * Returns a new Duration object whose
+ * value is -this.
+ *
+ *
+ * Since the Duration class is immutable, this method
+ * doesn't change the value of this object. It simply computes
+ * a new Duration object and returns it.
+ *
+ * @return
+ * always return a non-null valid Duration object.
+ */
+ public abstract Duration negate();
+
+ /**
+ *
Converts the years and months fields into the days field + * by using a specific time instant as the reference point.
+ * + *For example, duration of one month normalizes to 31 days + * given the start time instance "July 8th 2003, 17:40:32".
+ * + *Formally, the computation is done as follows:
+ *Note that since the Calendar class uses int to
+ * hold the value of year and month, this method may produce
+ * an unexpected result if this duration object holds
+ * a very large value in the years or months fields.
Calendar reference point.
+ *
+ * @return Duration of years and months of this Duration as days.
+ *
+ * @throws NullPointerException If the startTimeInstant parameter is null.
+ */
+ public abstract Duration normalizeWith(final Calendar startTimeInstant);
+
+ /**
+ * Partial order relation comparison with this Duration instance.
Comparison result must be in accordance with + * W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2, + * Order relation on duration.
+ * + *Return:
+ *Duration is shorter than duration parameterDuration is equal to duration parameterDuration is longer than duration parameterthis Durationand duration parameter as
+ * {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER}
+ * or {@link DatatypeConstants#INDETERMINATE}.
+ *
+ * @throws UnsupportedOperationException If the underlying implementation
+ * cannot reasonably process the request, e.g. W3C XML Schema allows for
+ * arbitrarily large/small/precise values, the request may be beyond the
+ * implementations capability.
+ * @throws NullPointerException if duration is null.
+ *
+ * @see #isShorterThan(Duration)
+ * @see #isLongerThan(Duration)
+ */
+ public abstract int compare(final Duration duration);
+
+ /**
+ * Checks if this duration object is strictly longer than
+ * another Duration object.
Duration X is "longer" than Y if and only if X>Y + * as defined in the section 3.2.6.2 of the XML Schema 1.0 + * specification.
+ * + *For example, "P1D" (one day) > "PT12H" (12 hours) and + * "P2Y" (two years) > "P23M" (23 months).
+ * + * @param durationDuration to test this Duration against.
+ *
+ * @throws UnsupportedOperationException If the underlying implementation
+ * cannot reasonably process the request, e.g. W3C XML Schema allows for
+ * arbitrarily large/small/precise values, the request may be beyond the
+ * implementations capability.
+ * @throws NullPointerException If duration is null.
+ *
+ * @return
+ * true if the duration represented by this object
+ * is longer than the given duration. false otherwise.
+ *
+ * @see #isShorterThan(Duration)
+ * @see #compare(Duration duration)
+ */
+ public boolean isLongerThan(final Duration duration) {
+ return compare(duration) == DatatypeConstants.GREATER;
+ }
+
+ /**
+ * Checks if this duration object is strictly shorter than
+ * another Duration object.
Duration to test this Duration against.
+ *
+ * @return true if duration parameter is shorter than this Duration,
+ * else false.
+ *
+ * @throws UnsupportedOperationException If the underlying implementation
+ * cannot reasonably process the request, e.g. W3C XML Schema allows for
+ * arbitrarily large/small/precise values, the request may be beyond the
+ * implementations capability.
+ * @throws NullPointerException if duration is null.
+ *
+ * @see #isLongerThan(Duration duration)
+ * @see #compare(Duration duration)
+ */
+ public boolean isShorterThan(final Duration duration) {
+ return compare(duration) == DatatypeConstants.LESSER;
+ }
+
+ /**
+ * Checks if this duration object has the same duration
+ * as another Duration object.
For example, "P1D" (1 day) is equal to "PT24H" (24 hours).
+ * + *Duration X is equal to Y if and only if time instant + * t+X and t+Y are the same for all the test time instants + * specified in the section 3.2.6.2 of the XML Schema 1.0 + * specification.
+ * + *Note that there are cases where two Durations are
+ * "incomparable" to each other, like one month and 30 days.
+ * For example,
+ * !new Duration("P1M").isShorterThan(new Duration("P30D"))
+ * !new Duration("P1M").isLongerThan(new Duration("P30D"))
+ * !new Duration("P1M").equals(new Duration("P30D"))
+ *
+ *
+ * @param duration
+ * A non-null valid Duration object.
+ *
+ * @return
+ * true if this duration is the same length as
+ * duration.
+ * false if duration is not a
+ * Duration object
+ * or its length is different from this duration.
+ *
+ * @throws UnsupportedOperationException If the underlying implementation
+ * cannot reasonably process the request, e.g. W3C XML Schema allows for
+ * arbitrarily large/small/precise values, the request may be beyond the
+ * implementations capability.
+ * @throws NullPointerException if parameter is null.
+ *
+ * @see #compare(Duration duration)
+ */
+ public boolean equals(final Object duration) {
+ if (duration == null) {
+ throw new NullPointerException();
+ }
+
+ if (!(duration instanceof Duration)) {
+ return false;
+ }
+
+ return compare((Duration) duration) == DatatypeConstants.EQUAL;
+ }
+
+ /**
+ * Returns a hash code consistent with the definition of the equals method.
+ *
+ * @see Object#hashCode()
+ */
+ public abstract int hashCode();
+
+ /**
+ * Returns a String representation of this Duration Object.
The result is formatted according to the XML Schema 1.0 spec and can be always parsed back later into the
+ * equivalent Duration Object by {@link DatatypeFactory#newDuration(String lexicalRepresentation)}.
Formally, the following holds for any Duration
+ * Object x:
+ * new Duration(x.toString()).equals(x) + *+ * + * @return A non-
null valid String representation of this Duration.
+ */
+ public String toString() {
+
+ StringBuffer buf = new StringBuffer();
+
+ if (getSign() < 0) {
+ buf.append('-');
+ }
+ buf.append('P');
+
+ BigInteger years = (BigInteger) getField(DatatypeConstants.YEARS);
+ if (years != null) {
+ buf.append(years + "Y");
+ }
+
+ BigInteger months = (BigInteger) getField(DatatypeConstants.MONTHS);
+ if (months != null) {
+ buf.append(months + "M");
+ }
+
+ BigInteger days = (BigInteger) getField(DatatypeConstants.DAYS);
+ if (days != null) {
+ buf.append(days + "D");
+ }
+
+ BigInteger hours = (BigInteger) getField(DatatypeConstants.HOURS);
+ BigInteger minutes = (BigInteger) getField(DatatypeConstants.MINUTES);
+ BigDecimal seconds = (BigDecimal) getField(DatatypeConstants.SECONDS);
+ if (hours != null || minutes != null || seconds != null) {
+ buf.append('T');
+ if (hours != null) {
+ buf.append(hours + "H");
+ }
+ if (minutes != null) {
+ buf.append(minutes + "M");
+ }
+ if (seconds != null) {
+ buf.append(toString(seconds) + "S");
+ }
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Turns {@link BigDecimal} to a string representation.
+ * + *Due to a behavior change in the {@link BigDecimal#toString()} + * method in JDK1.5, this had to be implemented here.
+ * + * @param bdBigDecimal to format as a String
+ *
+ * @return String representation of BigDecimal
+ */
+ private String toString(BigDecimal bd) {
+ String intString = bd.unscaledValue().toString();
+ int scale = bd.scale();
+
+ if (scale == 0) {
+ return intString;
+ }
+
+ /* Insert decimal point */
+ StringBuffer buf;
+ int insertionPoint = intString.length() - scale;
+ if (insertionPoint == 0) { /* Point goes right before intVal */
+ return "0." + intString;
+ } else if (insertionPoint > 0) { /* Point goes inside intVal */
+ buf = new StringBuffer(intString);
+ buf.insert(insertionPoint, '.');
+ } else { /* We must insert zeros between point and intVal */
+ buf = new StringBuffer(3 - insertionPoint + intString.length());
+ buf.append("0.");
+ for (int i = 0; i < -insertionPoint; i++) {
+ buf.append('0');
+ }
+ buf.append(intString);
+ }
+ return buf.toString();
+ }
+
+
+ /**
+ * Calls the {@link Calendar#getTimeInMillis} method. + * Prior to JDK1.4, this method was protected and therefore + * cannot be invoked directly.
+ * + *TODO: In future, this should be replaced by cal.getTimeInMillis().
Calendar to get time in milliseconds.
+ *
+ * @return Milliseconds of cal.
+ */
+ private static long getCalendarTimeInMillis(final Calendar cal) {
+ return cal.getTime().getTime();
+ }
+}
+
diff --git a/java/external/src/javax/xml/datatype/SecuritySupport.java b/java/external/src/javax/xml/datatype/SecuritySupport.java
new file mode 100644
index 0000000..e5dd355
--- /dev/null
+++ b/java/external/src/javax/xml/datatype/SecuritySupport.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.datatype;
+
+import java.security.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * This class is duplicated for each JAXP subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXP
+ * API.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+class SecuritySupport {
+
+
+ ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) { }
+ return cl;
+ }
+ });
+ }
+
+ String getSystemProperty(final String propName) {
+ return (String)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(propName);
+ }
+ });
+ }
+
+ FileInputStream getFileInputStream(final File file)
+ throws FileNotFoundException
+ {
+ try {
+ return (FileInputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(file);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException)e.getException();
+ }
+ }
+
+ InputStream getResourceAsStream(final ClassLoader cl,
+ final String name)
+ {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ InputStream ris;
+ if (cl == null) {
+ ris = ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = cl.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
+ }
+
+ boolean doesFileExist(final File f) {
+ return ((Boolean)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(f.exists());
+ }
+ })).booleanValue();
+ }
+
+}
diff --git a/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java b/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java
new file mode 100644
index 0000000..acf7bf9
--- /dev/null
+++ b/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java
@@ -0,0 +1,1046 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.datatype;
+
+import javax.xml.namespace.QName;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.TimeZone;
+import java.util.GregorianCalendar;
+
+/**
+ * Representation for W3C XML Schema 1.0 date/time datatypes.
+ * Specifically, these date/time datatypes are
+ * dateTime,
+ * time,
+ * date,
+ * gYearMonth,
+ * gMonthDay,
+ * gYear
+ * gMonth and
+ * gDay defined in the XML Namespace
+ * "http://www.w3.org/2001/XMLSchema".
+ * These datatypes are normatively defined in
+ * W3C XML Schema 1.0 Part 2, Section 3.2.7-14.
The table below defines the mapping between XML Schema 1.0 + * date/time datatype fields and this class' fields. It also summarizes + * the value constraints for the date and time fields defined in + * W3C XML Schema 1.0 Part 2, Appendix D, + * ISO 8601 Date and Time Formats.
+ * + * + *| + * Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation + * | + *||
|---|---|---|
| XML Schema 1.0 + * datatype + * field |
+ * Related XMLGregorianCalendar Accessor(s) |
+ * Value Range | + *
| year | + * {@link #getYear()} + {@link #getEon()} or + * {@link #getEonAndYear} + * |
+ * getYear() is a value between -(10^9-1) to (10^9)-1
+ * or {@link DatatypeConstants#FIELD_UNDEFINED}.+ * {@link #getEon()} is high order year value in billion of years. + * getEon() has values greater than or equal to (10^9) or less than or equal to -(10^9).
+ * A value of null indicates field is undefined.
+ * Given that XML Schema 1.0 errata states that the year zero
+ * will be a valid lexical value in a future version of XML Schema,
+ * this class allows the year field to be set to zero. Otherwise,
+ * the year field value is handled exactly as described
+ * in the errata and [ISO-8601-1988]. Note that W3C XML Schema 1.0
+ * validation does not allow for the year field to have a value of zero.
+ * |
+ *
| month | + *{@link #getMonth()} | + *1 to 12 or {@link DatatypeConstants#FIELD_UNDEFINED} | + *
| day | + *{@link #getDay()} | + * Independent of month, max range is 1 to 31 or {@link DatatypeConstants#FIELD_UNDEFINED}. + * The normative value constraint stated relative to month + * field's value is in W3C XML Schema 1.0 Part 2, Appendix D. + * |
+ *
| hour | + *{@link #getHour()} | + *+ * 0 to 24 or {@link DatatypeConstants#FIELD_UNDEFINED}. + * For a value of 24, the minute and second field must be zero per + * XML Schema Errata. + * | + *
| minute | + *{@link #getMinute()} | + *0 to 59 or {@link DatatypeConstants#FIELD_UNDEFINED} | + *
| second | + *
+ * {@link #getSecond()} + {@link #getMillisecond()}/1000 or + * {@link #getSecond()} + {@link #getFractionalSecond()} + * |
+ *
+ * {@link #getSecond()} from 0 to 60 or {@link DatatypeConstants#FIELD_UNDEFINED}. + * (Note: 60 only allowable for leap second.) + * {@link #getFractionalSecond()} allows for infinite precision over the range from 0.0 to 1.0 when + * the {@link #getSecond()} is defined. + * FractionalSecond is optional and has a value of null when it is undefined.+ * {@link #getMillisecond()} is the convenience + * millisecond precision of value of {@link #getFractionalSecond()}. + * |
+ *
| timezone | + *{@link #getTimezone()} | + *Number of minutes or {@link DatatypeConstants#FIELD_UNDEFINED}. + * Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes). + * | + *
All maximum value space constraints listed for the fields in the table
+ * above are checked by factory methods, @{link DatatypeFactory},
+ * setter methods and parse methods of
+ * this class. IllegalArgumentException is thrown when a
+ * parameter's value is outside the value constraint for the field or
+ * if the composite
+ * values constitute an invalid XMLGregorianCalendar instance (for example, if
+ * the 31st of June is specified).
+ *
The following operations are defined for this class: + *
Unset all fields to undefined.
+ * + *Set all int fields to {@link DatatypeConstants#FIELD_UNDEFINED} and reference fields + * to null.
+ */ + public abstract void clear(); + + /** + *Reset this XMLGregorianCalendar to its original values.
XMLGregorianCalendar is reset to the same values as when it was created with
+ * {@link DatatypeFactory#newXMLGregorianCalendar()},
+ * {@link DatatypeFactory#newXMLGregorianCalendar(String lexicalRepresentation)},
+ * {@link DatatypeFactory#newXMLGregorianCalendar(
+ * BigInteger year,
+ * int month,
+ * int day,
+ * int hour,
+ * int minute,
+ * int second,
+ * BigDecimal fractionalSecond,
+ * int timezone)},
+ * {@link DatatypeFactory#newXMLGregorianCalendar(
+ * int year,
+ * int month,
+ * int day,
+ * int hour,
+ * int minute,
+ * int second,
+ * int millisecond,
+ * int timezone)},
+ * {@link DatatypeFactory#newXMLGregorianCalendar(GregorianCalendar cal)},
+ * {@link DatatypeFactory#newXMLGregorianCalendarDate(
+ * int year,
+ * int month,
+ * int day,
+ * int timezone)},
+ * {@link DatatypeFactory#newXMLGregorianCalendarTime(
+ * int hours,
+ * int minutes,
+ * int seconds,
+ * int timezone)},
+ * {@link DatatypeFactory#newXMLGregorianCalendarTime(
+ * int hours,
+ * int minutes,
+ * int seconds,
+ * BigDecimal fractionalSecond,
+ * int timezone)} or
+ * {@link DatatypeFactory#newXMLGregorianCalendarTime(
+ * int hours,
+ * int minutes,
+ * int seconds,
+ * int milliseconds,
+ * int timezone)}.
+ *
reset() is designed to allow the reuse of existing XMLGregorianCalendars
+ * thus saving resources associated with the creation of new XMLGregorianCalendars.
Set low and high order component of XSD dateTime year field.
Unset this field by invoking the setter with a parameter value of null.
year parameter is
+ * outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setYear(BigInteger year);
+
+ /**
+ * Set year of XSD dateTime year field.
Unset this field by invoking the setter with a parameter value of + * {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + *Note: if the absolute value of the year parameter
+ * is less than 10^9, the eon component of the XSD year field is set to
+ * null by this method.
null.
+ */
+ public abstract void setYear(int year);
+
+ /**
+ * Set month.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param month value constraints summarized in month field of date/time field mapping table. + * + * @throws IllegalArgumentException ifmonth parameter is
+ * outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setMonth(int month);
+
+ /**
+ * Set days in month.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param day value constraints summarized in day field of date/time field mapping table. + * + * @throws IllegalArgumentException ifday parameter is
+ * outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setDay(int day);
+
+ /**
+ * Set the number of minutes in the timezone offset.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param offset value constraints summarized in + * timezone field of date/time field mapping table. + * + * @throws IllegalArgumentException ifoffset parameter is
+ * outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setTimezone(int offset);
+
+ /**
+ * Set time as one unit.
+ * + * @param hour value constraints are summarized in + * hour field of date/time field mapping table. + * @param minute value constraints are summarized in + * minute field of date/time field mapping table. + * @param second value constraints are summarized in + * second field of date/time field mapping table. + * + * @see #setTime(int, int, int, BigDecimal) + * + * @throws IllegalArgumentException if any parameter is + * outside value constraints for the field as specified in + * date/time field mapping table. + */ + public void setTime(int hour, int minute, int second) { + + setTime( + hour, + minute, + second, + null // fractional + ); + } + + /** + *Set hours.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param hour value constraints summarized in hour field of date/time field mapping table. + * + * @throws IllegalArgumentException ifhour parameter is outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setHour(int hour);
+
+ /**
+ * Set minutes.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param minute value constraints summarized in minute field of date/time field mapping table. + * + * @throws IllegalArgumentException ifminute parameter is outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setMinute(int minute);
+
+ /**
+ * Set seconds.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param second value constraints summarized in second field of date/time field mapping table. + * + * @throws IllegalArgumentException ifsecond parameter is outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public abstract void setSecond(int second);
+
+ /**
+ * Set milliseconds.
+ * + *Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @param millisecond value constraints summarized in + * millisecond field of date/time field mapping table. + * + * @throws IllegalArgumentException ifmillisecond parameter is outside value constraints for the field as specified
+ * in date/time field mapping table.
+ */
+ public abstract void setMillisecond(int millisecond);
+
+ /**
+ * Set fractional seconds.
+ * + *Unset this field by invoking the setter with a parameter value of null.
fractional parameter is outside value constraints for the field as specified
+ * in date/time field mapping table.
+ */
+ public abstract void setFractionalSecond(BigDecimal fractional);
+
+
+ /**
+ * Set time as one unit, including the optional infinite precision + * fractional seconds.
+ * + * @param hour value constraints are summarized in + * hour field of date/time field mapping table. + * @param minute value constraints are summarized in + * minute field of date/time field mapping table. + * @param second value constraints are summarized in + * second field of date/time field mapping table. + * @param fractional value ofnull indicates this optional
+ * field is not set.
+ *
+ * @throws IllegalArgumentException if any parameter is
+ * outside value constraints for the field as specified in
+ * date/time field mapping table.
+ */
+ public void setTime(
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fractional) {
+
+ setHour(hour);
+ setMinute(minute);
+ setSecond(second);
+ setFractionalSecond(fractional);
+ }
+
+
+ /**
+ * Set time as one unit, including optional milliseconds.
+ * + * @param hour value constraints are summarized in + * hour field of date/time field mapping table. + * @param minute value constraints are summarized in + * minute field of date/time field mapping table. + * @param second value constraints are summarized in + * second field of date/time field mapping table. + * @param millisecond value of {@link DatatypeConstants#FIELD_UNDEFINED} indicates this + * optional field is not set. + * + * @throws IllegalArgumentException if any parameter is + * outside value constraints for the field as specified in + * date/time field mapping table. + */ + public void setTime(int hour, int minute, int second, int millisecond) { + + setHour(hour); + setMinute(minute); + setSecond(second); + setMillisecond(millisecond); + } + + /** + *Return high order component for XML Schema 1.0 dateTime datatype field for
+ * year.
+ * null if this optional part of the year field is not defined.
Value constraints for this value are summarized in + * year field of date/time field mapping table.
+ * @return eon of thisXMLGregorianCalendar. The value
+ * returned is an integer multiple of 10^9.
+ *
+ * @see #getYear()
+ * @see #getEonAndYear()
+ */
+ public abstract BigInteger getEon();
+
+ /**
+ * Return low order component for XML Schema 1.0 dateTime datatype field for
+ * year or {@link DatatypeConstants#FIELD_UNDEFINED}.
Value constraints for this value are summarized in + * year field of date/time field mapping table.
+ * + * @return year of thisXMLGregorianCalendar.
+ *
+ * @see #getEon()
+ * @see #getEonAndYear()
+ */
+ public abstract int getYear();
+
+ /**
+ * Return XML Schema 1.0 dateTime datatype field for
+ * year.
Value constraints for this value are summarized in + * year field of date/time field mapping table.
+ * + * @return sum ofeon and BigInteger.valueOf(year)
+ * when both fields are defined. When only year is defined,
+ * return it. When both eon and year are not
+ * defined, return null.
+ *
+ * @see #getEon()
+ * @see #getYear()
+ */
+ public abstract BigInteger getEonAndYear();
+
+ /**
+ * Return number of month or {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + *Value constraints for this value are summarized in + * month field of date/time field mapping table.
+ * + * @return year of thisXMLGregorianCalendar.
+ *
+ */
+ public abstract int getMonth();
+
+ /**
+ * Return day in month or {@link DatatypeConstants#FIELD_UNDEFINED}.
+ *
+ * Value constraints for this value are summarized in + * day field of date/time field mapping table.
+ * + * @see #setDay(int) + */ + public abstract int getDay(); + + /** + * Return timezone offset in minutes or + * {@link DatatypeConstants#FIELD_UNDEFINED} if this optional field is not defined. + * + *Value constraints for this value are summarized in + * timezone field of date/time field mapping table.
+ * + * @see #setTimezone(int) + */ + public abstract int getTimezone(); + + /** + * Return hours or {@link DatatypeConstants#FIELD_UNDEFINED}. + * Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. + * + *Value constraints for this value are summarized in + * hour field of date/time field mapping table.
+ * @see #setTime(int, int, int) + */ + public abstract int getHour(); + + /** + * Return minutes or {@link DatatypeConstants#FIELD_UNDEFINED}. + * Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. + * + *Value constraints for this value are summarized in + * minute field of date/time field mapping table.
+ * @see #setTime(int, int, int) + */ + public abstract int getMinute(); + + /** + *Return seconds or {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + *Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. + * When this field is not defined, the optional xs:dateTime + * fractional seconds field, represented by + * {@link #getFractionalSecond()} and {@link #getMillisecond()}, + * must not be defined.
+ * + *Value constraints for this value are summarized in + * second field of date/time field mapping table.
+ * + * @return Second of thisXMLGregorianCalendar.
+ *
+ * @see #getFractionalSecond()
+ * @see #getMillisecond()
+ * @see #setTime(int, int, int)
+ */
+ public abstract int getSecond();
+
+ /**
+ * Return millisecond precision of {@link #getFractionalSecond()}.
+ * + *This method represents a convenience accessor to infinite
+ * precision fractional second value returned by
+ * {@link #getFractionalSecond()}. The returned value is the rounded
+ * down to milliseconds value of
+ * {@link #getFractionalSecond()}. When {@link #getFractionalSecond()}
+ * returns null, this method must return
+ * {@link DatatypeConstants#FIELD_UNDEFINED}.
Value constraints for this value are summarized in + * second field of date/time field mapping table.
+ * + * @return Millisecond of thisXMLGregorianCalendar.
+ *
+ * @see #getFractionalSecond()
+ * @see #setTime(int, int, int)
+ */
+ public int getMillisecond() {
+
+ BigDecimal fractionalSeconds = getFractionalSecond();
+
+ // is field undefined?
+ if (fractionalSeconds == null) {
+ return DatatypeConstants.FIELD_UNDEFINED;
+ }
+
+ return getFractionalSecond().movePointRight(3).intValue();
+ }
+
+ /**
+ * Return fractional seconds.
+ * + *null is returned when this optional field is not defined.
Value constraints are detailed in + * second field of date/time field mapping table.
+ * + *This optional field can only have a defined value when the + * xs:dateTime second field, represented by {@link #getSecond()}, + * does not return {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * + * @return fractional seconds of thisXMLGregorianCalendar.
+ *
+ * @see #getSecond()
+ * @see #setTime(int, int, int, BigDecimal)
+ */
+ public abstract BigDecimal getFractionalSecond();
+
+ // comparisons
+ /**
+ * Compare two instances of W3C XML Schema 1.0 date/time datatypes + * according to partial order relation defined in + * W3C XML Schema 1.0 Part 2, Section 3.2.7.3, + * Order relation on dateTime.
+ * + *xsd:dateTime datatype field mapping to accessors of
+ * this class are defined in
+ * date/time field mapping table.
XMLGregorianCalendar to compare
+ *
+ * @return The relationship between this XMLGregorianCalendar and
+ * the specified xmlGregorianCalendar as
+ * {@link DatatypeConstants#LESSER},
+ * {@link DatatypeConstants#EQUAL},
+ * {@link DatatypeConstants#GREATER} or
+ * {@link DatatypeConstants#INDETERMINATE}.
+ *
+ * @throws NullPointerException if xmlGregorianCalendar is null.
+ */
+ public abstract int compare(XMLGregorianCalendar xmlGregorianCalendar);
+
+ /**
+ * Normalize this instance to UTC.
+ * + *2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z
+ *Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).
+ * + * @returnthis XMLGregorianCalendar normalized to UTC.
+ */
+ public abstract XMLGregorianCalendar normalize();
+
+ /**
+ * Indicates whether parameter obj is "equal to" this one.
true when obj is an instance of XMLGregorianCalendar
+ * and {@link #compare(XMLGregorianCalendar obj)} returns {@link DatatypeConstants#EQUAL}, otherwise false.
+ *
+ * @throws NullPointerException If obj is null.
+ */
+ public boolean equals(Object obj) {
+
+ if (obj == null) {
+ throw new NullPointerException("Cannot test null for equality with this XMLGregorianCalendar");
+ }
+
+ boolean result = false;
+
+ if (obj instanceof XMLGregorianCalendar) {
+ result = compare((XMLGregorianCalendar) obj) == DatatypeConstants.EQUAL;
+ }
+ return result;
+ }
+
+ /**
+ * Returns a hash code consistent with the definition of the equals method.
+ * + * @return hash code of this object. + */ + public int hashCode() { + + // Following two dates compare to EQUALS since in different timezones. + // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 + // + // Must ensure both instances generate same hashcode by normalizing + // this to UTC timezone. + int timezone = getTimezone(); + if (timezone == DatatypeConstants.FIELD_UNDEFINED) { + timezone = 0; + } + XMLGregorianCalendar gc = this; + if (timezone != 0) { + gc = this.normalize(); + } + return gc.getYear() + + gc.getMonth() + + gc.getDay() + + gc.getHour() + + gc.getMinute() + + gc.getSecond(); + } + + /** + *Return the lexical representation of this instance.
+ * The format is specified in
+ * XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
+ * Lexical Representation".
Specific target lexical representation format is determined by + * {@link #getXMLSchemaType()}.
+ * + * @return XML, asString, representation of this XMLGregorianCalendar
+ *
+ * @throws IllegalStateException if the combination of set fields
+ * does not match one of the eight defined XML Schema builtin date/time datatypes.
+ */
+ public abstract String toXMLFormat();
+
+ /**
+ * Return the name of the XML Schema date/time type that this instance + * maps to. Type is computed based on fields that are set.
+ * + *|
+ * Required fields for XML Schema 1.0 Date/Time Datatypes. + * (timezone is optional for all date/time datatypes) + * |
+ * ||||||
|---|---|---|---|---|---|---|
| Datatype | + *year | + *month | + *day | + *hour | + *minute | + *second | + *
| {@link DatatypeConstants#DATETIME} | + *X | + *X | + *X | + *X | + *X | + *X | + *
| {@link DatatypeConstants#DATE} | + *X | + *X | + *X | + *+ * | + * | + * |
| {@link DatatypeConstants#TIME} | + *+ * | + * | + * | X | + *X | + *X | + *
| {@link DatatypeConstants#GYEARMONTH} | + *X | + *X | + *+ * | + * | + * | + * |
| {@link DatatypeConstants#GMONTHDAY} | + *+ * | X | + *X | + *+ * | + * | + * |
| {@link DatatypeConstants#GYEAR} | + *X | + *+ * | + * | + * | + * | + * |
| {@link DatatypeConstants#GMONTH} | + *+ * | X | + *+ * | + * | + * | + * |
| {@link DatatypeConstants#GDAY} | + *+ * | + * | X | + *+ * | + * | + * |
Returns a String representation of this XMLGregorianCalendar Object.
The result is a lexical representation generated by {@link #toXMLFormat()}.
+ * + * @return A non-null valid String representation of this XMLGregorianCalendar.
+ *
+ * @throws IllegalStateException if the combination of set fields
+ * does not match one of the eight defined XML Schema builtin date/time datatypes.
+ *
+ * @see #toXMLFormat()
+ */
+ public String toString() {
+
+ return toXMLFormat();
+ }
+
+ /**
+ * Validate instance by getXMLSchemaType() constraints.
+ * @return true if data values are valid.
+ */
+ public abstract boolean isValid();
+
+ /**
+ * Add duration to this instance.
The computation is specified in
+ * XML Schema 1.0 Part 2, Appendix E,
+ * Adding durations to dateTimes>.
+ * date/time field mapping table
+ * defines the mapping from XML Schema 1.0 dateTime fields
+ * to this class' representation of those fields.
XMLGregorianCalendar.
+ *
+ * @throws NullPointerException when duration parameter is null.
+ */
+ public abstract void add(Duration duration);
+
+ /**
+ * Convert this XMLGregorianCalendar to a {@link GregorianCalendar}.
When this instance has an undefined field, this
+ * conversion relies on the java.util.GregorianCalendar default
+ * for its corresponding field. A notable difference between
+ * XML Schema 1.0 date/time datatypes and java.util.GregorianCalendar
+ * is that Timezone value is optional for date/time datatypes and it is
+ * a required field for java.util.GregorianCalendar. See javadoc
+ * for java.util.TimeZone.getDefault() on how the default
+ * is determined. To explicitly specify the TimeZone
+ * instance, see
+ * {@link #toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar)}.
+ * Field by Field Conversion from this class to
+ * java.util.GregorianCalendar
+ * |
+ * |
|---|---|
java.util.GregorianCalendar field |
+ * javax.xml.datatype.XMLGregorianCalendar field |
+ *
ERA |
+ * {@link #getEonAndYear()}.signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD |
+ *
YEAR |
+ * {@link #getEonAndYear()}.abs().intValue()* |
+ *
MONTH |
+ * {@link #getMonth()} - {@link DatatypeConstants#JANUARY} + {@link GregorianCalendar#JANUARY} | + *
DAY_OF_MONTH |
+ * {@link #getDay()} | + *
HOUR_OF_DAY |
+ * {@link #getHour()} | + *
MINUTE |
+ * {@link #getMinute()} | + *
SECOND |
+ * {@link #getSecond()} | + *
MILLISECOND |
+ * get millisecond order from {@link #getFractionalSecond()}* | + *
GregorianCalendar.setTimeZone(TimeZone) |
+ * {@link #getTimezone()} formatted into Custom timezone id | + *
To ensure consistency in conversion implementations, the new
+ * GregorianCalendar should be instantiated in following
+ * manner.
+ *
timeZone value as defined above, create a new
+ * java.util.GregorianCalendar(timeZone,Locale.getDefault()).
+ * GregorianCalendar.setGregorianChange(
+ * new Date(Long.MIN_VALUE)).Calendar.set(int,int)Convert this XMLGregorianCalendar along with provided parameters
+ * to a {@link GregorianCalendar} instance.
Since XML Schema 1.0 date/time datetypes has no concept of
+ * timezone ids or daylight savings timezone ids, this conversion operation
+ * allows the user to explicitly specify one with
+ * timezone parameter.
To compute the return value's TimeZone field,
+ *
timeZone is non-null,
+ * it is the timezone field.this.getTimezone() != FIELD_UNDEFINED,
+ * create a java.util.TimeZone with a custom timezone id
+ * using the this.getTimezone().defaults.getTimezone() != FIELD_UNDEFINED,
+ * create a java.util.TimeZone with a custom timezone id
+ * using defaults.getTimezone().GregorianCalendar default timezone value
+ * for the host is defined as specified by
+ * java.util.TimeZone.getDefault().To ensure consistency in conversion implementations, the new
+ * GregorianCalendar should be instantiated in following
+ * manner.
+ *
java.util.GregorianCalendar(TimeZone,
+ * Locale) with TimeZone set as specified above and the
+ * Locale parameter.
+ * GregorianCalendar.setGregorianChange(
+ * new Date(Long.MIN_VALUE)).Calendar.set(int,int)null is a legal value.
+ * @param aLocale provide explicit Locale. Use default GregorianCalendar locale if
+ * value is null.
+ * @param defaults provide default field values to use when corresponding
+ * field for this instance is FIELD_UNDEFINED or null.
+ * If defaultsis null or a field
+ * within the specified defaults is undefined,
+ * just use java.util.GregorianCalendar defaults.
+ * @return a java.util.GregorianCalendar conversion of this instance.
+ */
+ public abstract GregorianCalendar toGregorianCalendar(
+ java.util.TimeZone timezone,
+ java.util.Locale aLocale,
+ XMLGregorianCalendar defaults);
+
+ /**
+ * Returns a java.util.TimeZone for this class.
If timezone field is defined for this instance, + * returns TimeZone initialized with custom timezone id + * of zoneoffset. If timezone field is undefined, + * try the defaultZoneoffset that was passed in. + * If defaultZoneoffset is FIELD_UNDEFINED, return + * default timezone for this host. + * (Same default as java.util.GregorianCalendar).
+ * + * @param defaultZoneoffset default zoneoffset if this zoneoffset is + * {@link DatatypeConstants#FIELD_UNDEFINED}. + * + * @return TimeZone for this. + */ + public abstract TimeZone getTimeZone(int defaultZoneoffset); + + + + /** + *Creates and returns a copy of this object.
+ * + * @return copy of thisObject
+ */
+ public abstract Object clone();
+}
diff --git a/java/external/src/javax/xml/parsers/DocumentBuilder.java b/java/external/src/javax/xml/parsers/DocumentBuilder.java
index e701345..a352a30 100644
--- a/java/external/src/javax/xml/parsers/DocumentBuilder.java
+++ b/java/external/src/javax/xml/parsers/DocumentBuilder.java
@@ -1,77 +1,44 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2001, Sun Microsystems,
- * Inc., http://www.sun.com. For more information on the Apache Software
- * Foundation, please see + * {@link Document} from XML.
* * An instance of this class can be obtained from the - * {@link javax.xml.parsers.DocumentBuilderFactory#newDocumentBuilder() - * DocumentBuilderFactory.newDocumentBuilder} method. Once + * {@link DocumentBuilderFactory#newDocumentBuilder()} method. Once * an instance of this class is obtained, XML can be parsed from a * variety of input sources. These input sources are InputStreams, * Files, URLs, and SAX InputSources.
@@ -80,38 +47,59 @@ import org.w3c.dom.DOMImplementation;
* does not require that the implementor of the underlying DOM
* implementation use a SAX parser to parse XML document into a
* Document. It merely requires that the implementation
- * communicate with the application using these existing APIs.
+ * communicate with the application using these existing APIs.
*
- * An implementation of DocumentBuilder is NOT
- * guaranteed to behave as per the specification if it is used concurrently by
- * two or more threads. It is recommended to have one instance of the
- * DocumentBuilder per thread or it is upto the application to
- * make sure about the use of DocumentBuilder from more than one
- * thread.
- *
- * @since JAXP 1.0
- * @version 1.0
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
public abstract class DocumentBuilder {
-
+
+
+ /** Protected constructor */
protected DocumentBuilder () {
}
+ /**
+ *
Reset this DocumentBuilder to its original configuration.
DocumentBuilder is reset to the same state as when it was created with
+ * {@link DocumentBuilderFactory#newDocumentBuilder()}.
+ * reset() is designed to allow the reuse of existing DocumentBuilders
+ * thus saving resources associated with the creation of new DocumentBuilders.
The reset DocumentBuilder is not guaranteed to have the same {@link EntityResolver} or {@link ErrorHandler}
+ * Objects, e.g. {@link Object#equals(Object obj)}. It is guaranteed to have a functionally equal
+ * EntityResolver and ErrorHandler.
InputStream as an XML
- * document and return a new DOM {@link org.w3c.dom.Document} object.
+ * Parse the content of the given InputStream as an XML
+ * document and return a new DOM {@link Document} object.
+ * An IllegalArgumentException is thrown if the
+ * InputStream is null.
*
* @param is InputStream containing the content to be parsed.
+ * @return Document result of parsing the
+ * InputStream
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the InputStream is null
* @see org.xml.sax.DocumentHandler
*/
public Document parse(InputStream is)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
@@ -121,45 +109,45 @@ public abstract class DocumentBuilder {
}
/**
- * Parse the content of the given InputStream as an XML
- * document and return a new DOM {@link org.w3c.dom.Document} object.
+ * Parse the content of the given InputStream as an
+ * XML document and return a new DOM {@link Document} object.
+ * An IllegalArgumentException is thrown if the
+ * InputStream is null.
*
* @param is InputStream containing the content to be parsed.
* @param systemId Provide a base for resolving relative URIs.
+ * @return A new DOM Document object.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the InputStream is null.
* @see org.xml.sax.DocumentHandler
- * @return A new DOM Document object.
*/
public Document parse(InputStream is, String systemId)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
InputSource in = new InputSource(is);
- in.setSystemId(systemId);
+ in.setSystemId(systemId);
return parse(in);
}
/**
* Parse the content of the given URI as an XML document
- * and return a new DOM {@link org.w3c.dom.Document} object.
+ * and return a new DOM {@link Document} object.
+ * An IllegalArgumentException is thrown if the
+ * URI is null null.
*
* @param uri The location of the content to be parsed.
+ * @return A new DOM Document object.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the URI is null.
* @see org.xml.sax.DocumentHandler
- * @return A new DOM Document object.
*/
public Document parse(String uri)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (uri == null) {
throw new IllegalArgumentException("URI cannot be null");
}
@@ -170,39 +158,39 @@ public abstract class DocumentBuilder {
/**
* Parse the content of the given file as an XML document
- * and return a new DOM {@link org.w3c.dom.Document} object.
+ * and return a new DOM {@link Document} object.
+ * An IllegalArgumentException is thrown if the
+ * File is null null.
*
* @param f The file containing the XML to parse.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the file is null.
* @see org.xml.sax.DocumentHandler
* @return A new DOM Document object.
*/
- public Document parse(File f)
- throws SAXException, IOException
- {
+ public Document parse(File f) throws SAXException, IOException {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
-
+
String uri = "file:" + f.getAbsolutePath();
- if (File.separatorChar == '\\') {
- uri = uri.replace('\\', '/');
- }
+ if (File.separatorChar == '\\') {
+ uri = uri.replace('\\', '/');
+ }
InputSource in = new InputSource(uri);
return parse(in);
}
/**
* Parse the content of the given input source as an XML document
- * and return a new DOM {@link org.w3c.dom.Document} object.
+ * and return a new DOM {@link Document} object.
+ * An IllegalArgumentException is thrown if the
+ * InputSource is null null.
*
* @param is InputSource containing the content to be parsed.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the InputSource is null.
* @see org.xml.sax.DocumentHandler
* @return A new DOM Document object.
*/
@@ -232,7 +220,7 @@ public abstract class DocumentBuilder {
public abstract boolean isValidating();
/**
- * Specify the {@link org.xml.sax.EntityResolver} to be used to resolve
+ * Specify the {@link EntityResolver} to be used to resolve
* entities present in the XML document to be parsed. Setting
* this to null will result in the underlying
* implementation using it's own default implementation and
@@ -242,28 +230,22 @@ public abstract class DocumentBuilder {
* present in the XML document to be parsed.
*/
- public abstract void setEntityResolver(org.xml.sax.EntityResolver er);
+ public abstract void setEntityResolver(EntityResolver er);
/**
- * Specify the {@link org.xml.sax.ErrorHandler} to be used to report
- * errors present in the XML document to be parsed. Setting
- * this to null will result in the underlying
+ * Specify the {@link ErrorHandler} to be used by the parser.
+ * Setting this to null will result in the underlying
* implementation using it's own default implementation and
* behavior.
*
- * @param eh The ErrorHandler to be used to report errors
- * present in the XML document to be parsed.
+ * @param eh The ErrorHandler to be used by the parser.
*/
- public abstract void setErrorHandler(org.xml.sax.ErrorHandler eh);
+ public abstract void setErrorHandler(ErrorHandler eh);
/**
- * Obtain a new instance of a DOM {@link org.w3c.dom.Document} object
- * to build a DOM tree with. An alternative way to create a DOM
- * Document object is to use the
- * {@link #getDOMImplementation() getDOMImplementation}
- * method to get a DOM Level 2 DOMImplementation object and then use
- * DOM Level 2 methods on that object to create a DOM Document object.
+ * Obtain a new instance of a DOM {@link Document} object
+ * to build a DOM tree with.
*
* @return A new instance of a DOM Document object.
*/
@@ -271,10 +253,73 @@ public abstract class DocumentBuilder {
public abstract Document newDocument();
/**
- * Obtain an instance of a {@link org.w3c.dom.DOMImplementation} object.
+ * Obtain an instance of a {@link DOMImplementation} object.
*
* @return A new instance of a DOMImplementation.
*/
public abstract DOMImplementation getDOMImplementation();
+
+ /** Get current state of canonicalization.
+ * + * @return current state canonicalization control + */ + /* + public boolean getCanonicalization() { + return canonicalState; + } + */ + + /**Get a reference to the the {@link Schema} being used by + * the XML processor.
+ * + *If no schema is being used, null is returned.
null
+ * if none in use
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public Schema getSchema() {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+
+ /**
+ * Get the XInclude processing mode for this parser.
+ * + * @return + * the return value of + * the {@link DocumentBuilderFactory#isXIncludeAware()} + * when this parser was created from factory. + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @since 1.5 + * + * @see DocumentBuilderFactory#setXIncludeAware(boolean) + */ + public boolean isXIncludeAware() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + } } diff --git a/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java b/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java index 1e5164a..135a1b6 100644 --- a/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java +++ b/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java @@ -1,78 +1,38 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, Sun Microsystems, - * Inc., http://www.sun.com. For more information on the Apache Software - * Foundation, please seeDocumentBuilderFactory class is
- * NOT guaranteed to be thread safe. It is up to the user application
- * to make sure about the use of the DocumentBuilderFactory from
- * more than one thread. Alternatively the application can have one instance
- * of the DocumentBuilderFactory per thread.
- * An application can use the same instance of the factory to obtain one or
- * more instances of the DocumentBuilder provided the instance
- * of the factory isn't being used in more than one thread at a time.
- *
- * @since JAXP 1.0
- * @version 1.0
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
public abstract class DocumentBuilderFactory {
+
+ /** The default property name according to the JAXP spec */
+ private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.DocumentBuilderFactory";
+
private boolean validating = false;
private boolean namespaceAware = false;
private boolean whitespace = false;
@@ -80,8 +40,9 @@ public abstract class DocumentBuilderFactory {
private boolean ignoreComments = false;
private boolean coalescing = false;
- protected DocumentBuilderFactory () {
+ private boolean canonicalState = false;
+ protected DocumentBuilderFactory () {
}
/**
@@ -102,6 +63,12 @@ public abstract class DocumentBuilderFactory {
* format and contains the fully qualified name of the
* implementation class with the key being the system property defined
* above.
+ *
+ * The jaxp.properties file is read only once by the JAXP implementation
+ * and it's values are then cached for future use. If the file does not exist
+ * when the first attempt is made to read from it, no further attempts are
+ * made to check for its existence. It is not possible to change the value
+ * of any property in jaxp.properties after it has been read for the first time.
*
* DocumentBuilderFactory it can use the factory to
* configure and obtain parser instances.
+ *
+ *
+ * Setting the jaxp.debug system property will cause
+ * this method to print a lot of debug messages
+ * to System.err about what it is doing and where it is looking at.
If you have problems loading {@link DocumentBuilder}s, try:
+ *+ * java -Djaxp.debug=1 YourProgram .... + *+ * + * @return New instance of a
DocumentBuilderFactory
*
* @exception FactoryConfigurationError if the implementation is not
* available or cannot be instantiated.
*/
-
- public static DocumentBuilderFactory newInstance()
- throws FactoryConfigurationError
- {
+ public static DocumentBuilderFactory newInstance() {
try {
return (DocumentBuilderFactory) FactoryFinder.find(
/* The default property name according to the JAXP spec */
"javax.xml.parsers.DocumentBuilderFactory",
/* The fallback implementation class name */
- null);
+ "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
}
+
}
-
+
/**
* Creates a new instance of a {@link javax.xml.parsers.DocumentBuilder}
* using the currently configured parameters.
@@ -168,7 +146,24 @@ public abstract class DocumentBuilderFactory {
* Specifies that the parser produced by this code will
* validate documents as they are parsed. By default the value of this
* is set to false.
- *
+ *
+ * + * Note that "the validation" here means + * a validating + * parser as defined in the XML recommendation. + * In other words, it essentially just controls the DTD validation. + * (except the legacy two properties defined in JAXP 1.2. + * See here for more details.) + *
+ * + *+ * To use modern schema languages such as W3C XML Schema or + * RELAX NG instead of DTD, you can configure your parser to be + * a non-validating parser by leaving the {@link #setValidating(boolean)} + * method false, then use the {@link #setSchema(Schema)} + * method to associate a schema to a parser. + *
+ * * @param validating true if the parser produced will validate documents * as they are parsed; false otherwise. */ @@ -210,9 +205,11 @@ public abstract class DocumentBuilderFactory { } /** - * Specifies that the parser produced by this code will + *Specifies that the parser produced by this code will
* ignore comments. By default the value of this is set to false
- *
+ * .
boolean value to ignore comments during processing
*/
public void setIgnoringComments(boolean ignoreComments) {
@@ -330,4 +327,233 @@ public abstract class DocumentBuilderFactory {
*/
public abstract Object getAttribute(String name)
throws IllegalArgumentException;
+
+ /**
+ * Set a feature for this DocumentBuilderFactory and DocumentBuilders created by this factory.
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * An {@link ParserConfigurationException} is thrown if this DocumentBuilderFactory or the
+ * DocumentBuilders it creates cannot support the feature.
+ * It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.
+ *
+ * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. + * When the feature is:
+ *true: the implementation will limit XML processing to conform to implementation limits.
+ * Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+ * If XML processing is limited for security reasons, it will be reported via a call to the registered
+ * {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
+ * See {@link DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
+ * false: the implementation will processing XML according to the XML specifications without
+ * regard to possible implementation limits.
+ * true or false.
+ *
+ * @throws ParserConfigurationException if this DocumentBuilderFactory or the DocumentBuilders
+ * it creates cannot support this feature.
+ * @throws NullPointerException If the name parameter is null.
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws ParserConfigurationException;
+
+ /**
+ * Get the state of the named feature.
+ * + *
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * An {@link ParserConfigurationException} is thrown if this DocumentBuilderFactory or the
+ * DocumentBuilders it creates cannot support the feature.
+ * It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.
+ *
DocumentBuilderFactory
+ * or the DocumentBuilders it creates cannot support this feature.
+ */
+ public abstract boolean getFeature(String name)
+ throws ParserConfigurationException;
+
+
+ /** Get current state of canonicalization.
+ * + * @return current state canonicalization control + */ + /* + public boolean getCanonicalization() { + return canonicalState; + } + */ + + + /** + * Gets the {@link Schema} object specified through + * the {@link #setSchema(Schema schema)} method. + * + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @return + * the {@link Schema} object that was last set through + * the {@link #setSchema(Schema)} method, or null + * if the method was not invoked since a {@link SAXParserFactory} + * is created. + * + * @since 1.5 + */ + public Schema getSchema() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + + } + + /*Set canonicalization control to true or
+ * false.
Set the {@link Schema} to be used by parsers created + * from this factory. + * + *
+ * When a {@link Schema} is non-null, a parser will use a validator + * created from it to validate documents before it passes information + * down to the application. + * + *
When errors are found by the validator, the parser is responsible + * to report them to the user-specified {@link org.w3c.dom.DOMErrorHandler} + * (or if the error handler is not set, ignore them or throw them), just + * like any other errors found by the parser itself. + * In other words, if the user-specified {@link org.w3c.dom.DOMErrorHandler} + * is set, it must receive those errors, and if not, they must be + * treated according to the implementation specific + * default error handling rules. + * + *
+ * A validator may modify the outcome of a parse (for example by + * adding default values that were missing in documents), and a parser + * is responsible to make sure that the application will receive + * modified DOM trees. + * + *
+ * Initialy, null is set as the {@link Schema}. + * + *
+ * This processing will take effect even if + * the {@link #isValidating()} method returns false. + * + *
It is an error to use
+ * the http://java.sun.com/xml/jaxp/properties/schemaSource
+ * property and/or the http://java.sun.com/xml/jaxp/properties/schemaLanguage
+ * property in conjunction with a {@link Schema} object.
+ * Such configuration will cause a {@link ParserConfigurationException}
+ * exception when the {@link #newDocumentBuilder()} is invoked.
+ * A parser must be able to work with any {@link Schema}
+ * implementation. However, parsers and schemas are allowed
+ * to use implementation-specific custom mechanisms
+ * as long as they yield the result described in the specification.
+ *
+ * @param schema Schema to use or null to remove a schema.
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public void setSchema(Schema schema) {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+
+
+ /**
+ *
Set state of XInclude processing.
+ * + *If XInclude markup is found in the document instance, should it be + * processed as specified in + * XML Inclusions (XInclude) Version 1.0.
+ * + *XInclude processing defaults to false.
true or
+ * false
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public void setXIncludeAware(final boolean state) {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+ /**
+ * Get state of XInclude processing.
+ * + * @return current state of XInclude processing + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @since 1.5 + */ + public boolean isXIncludeAware() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + } } diff --git a/java/external/src/javax/xml/parsers/FactoryConfigurationError.java b/java/external/src/javax/xml/parsers/FactoryConfigurationError.java index ba3b1ae..a58803d 100644 --- a/java/external/src/javax/xml/parsers/FactoryConfigurationError.java +++ b/java/external/src/javax/xml/parsers/FactoryConfigurationError.java @@ -1,58 +1,21 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, Sun Microsystems, - * Inc., http://www.sun.com. For more information on the Apache Software - * Foundation, please seeException that represents the error.
+ */
private Exception exception;
/**
@@ -74,10 +40,10 @@ public class FactoryConfigurationError extends Error {
* detail mesage.
*/
- public FactoryConfigurationError() {
- super();
- this.exception = null;
- }
+ public FactoryConfigurationError() {
+ super();
+ this.exception = null;
+ }
/**
* Create a new FactoryConfigurationError with
@@ -112,7 +78,6 @@ public class FactoryConfigurationError extends Error {
* @param e The exception to be encapsulated in a
* FactoryConfigurationError
* @param msg The detail message.
- * @param e The exception to be wrapped in a FactoryConfigurationError
*/
public FactoryConfigurationError(Exception e, String msg) {
@@ -152,10 +117,3 @@ public class FactoryConfigurationError extends Error {
return exception;
}
}
-
-
-
-
-
-
-
diff --git a/java/external/src/javax/xml/parsers/FactoryFinder.java b/java/external/src/javax/xml/parsers/FactoryFinder.java
index db36dd7..ad11f08 100644
--- a/java/external/src/javax/xml/parsers/FactoryFinder.java
+++ b/java/external/src/javax/xml/parsers/FactoryFinder.java
@@ -1,136 +1,116 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2001, Sun Microsystems,
- * Inc., http://www.sun.com. For more information on the Apache Software
- * Foundation, please see * + * This static method creates a new factory instance based + * on a system property setting or uses the platform default + * if no property has been defined.
+ *
+ * The system property that controls which Factory implementation
+ * to create is named "javax.xml.parsers.SAXParserFactory".
+ * This property names a class that is a concrete subclass of this
+ * abstract class. If no property is defined, a platform default
+ * will be used.
* - * Implementors of this class which wrap an underlying implementation + * Implementors of this class which wrap an underlaying implementation * can consider using the {@link org.xml.sax.helpers.ParserAdapter} * class to initially adapt their SAX1 impelemntation to work under - * this revised class.
+ * this revised class.
*
- * An implementation of SAXParser is NOT
- * guaranteed to behave as per the specification if it is used concurrently by
- * two or more threads. It is recommended to have one instance of the
- * SAXParser per thread or it is upto the application to
- * make sure about the use of SAXParser from more than one
- * thread.
- *
- * @since JAXP 1.0
- * @version 1.0
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
-
public abstract class SAXParser {
-
+
+ /**
+ *
Protected constructor to prevent instaniation. + * Use {@link javax.xml.parsers.SAXParserFactory#newSAXParser()}.
+ */ protected SAXParser () { } + /** + *Reset this SAXParser to its original configuration.
SAXParser is reset to the same state as when it was created with
+ * {@link SAXParserFactory#newSAXParser()}.
+ * reset() is designed to allow the reuse of existing SAXParsers
+ * thus saving resources associated with the creation of new SAXParsers.
The reset SAXParser is not guaranteed to have the same {@link Schema}
+ * Object, e.g. {@link Object#equals(Object obj)}. It is guaranteed to have a functionally equal
+ * Schema.
Parse the content of the given {@link java.io.InputStream} * instance as XML using the specified {@link org.xml.sax.HandlerBase}. * Use of the DefaultHandler version of this method is recommended as - * the HandlerBase class has been deprecated in SAX 2.0 + * the HandlerBase class has been deprecated in SAX 2.0.
* * @param is InputStream containing the content to be parsed. * @param hb The SAX HandlerBase to use. - * @exception IOException If any IO errors occur. - * @exception IllegalArgumentException If the given InputStream is null. - * @exception SAXException If the underlying parser throws a - * SAXException while parsing. + * + * @throws IllegalArgumentException If the given InputStream is null. + * @throws SAXException If parse produces a SAX error. + * @throws IOException If an IO error occurs interacting with the + *InputStream.
+ *
* @see org.xml.sax.DocumentHandler
- */
-
+ */
public void parse(InputStream is, HandlerBase hb)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
-
+
InputSource input = new InputSource(is);
this.parse(input, hb);
}
/**
- * Parse the content of the given {@link java.io.InputStream}
+ * Parse the content of the given {@link java.io.InputStream} * instance as XML using the specified {@link org.xml.sax.HandlerBase}. * Use of the DefaultHandler version of this method is recommended as - * the HandlerBase class has been deprecated in SAX 2.0 + * the HandlerBase class has been deprecated in SAX 2.0.
* * @param is InputStream containing the content to be parsed. * @param hb The SAX HandlerBase to use. * @param systemId The systemId which is needed for resolving relative URIs. - * @exception IOException If any IO errors occur. - * @exception IllegalArgumentException If the given InputStream is null. - * @exception SAXException If the underlying parser throws a - * SAXException while parsing. - * @see org.xml.sax.DocumentHandler - * version of this method instead. + * + * @throws IllegalArgumentException If the givenInputStream is
+ * null.
+ * @throws IOException If any IO error occurs interacting with the
+ * InputStream.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
+ * @see org.xml.sax.DocumentHandler version of this method instead.
*/
-
- public void parse(InputStream is, HandlerBase hb, String systemId)
- throws SAXException, IOException
- {
+ public void parse(
+ InputStream is,
+ HandlerBase hb,
+ String systemId)
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
-
+
InputSource input = new InputSource(is);
input.setSystemId(systemId);
this.parse(input, hb);
@@ -173,20 +169,19 @@ public abstract class SAXParser {
*
* @param is InputStream containing the content to be parsed.
* @param dh The SAX DefaultHandler to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the given InputStream is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the given InputStream is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
*/
-
public void parse(InputStream is, DefaultHandler dh)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
-
+
InputSource input = new InputSource(is);
this.parse(input, dh);
}
@@ -199,21 +194,22 @@ public abstract class SAXParser {
* @param is InputStream containing the content to be parsed.
* @param dh The SAX DefaultHandler to use.
* @param systemId The systemId which is needed for resolving relative URIs.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the given InputStream is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
- * @see org.xml.sax.DocumentHandler
- * version of this method instead.
+ *
+ * @throws IllegalArgumentException If the given InputStream is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
+ * @see org.xml.sax.DocumentHandler version of this method instead.
*/
-
- public void parse(InputStream is, DefaultHandler dh, String systemId)
- throws SAXException, IOException
- {
+ public void parse(
+ InputStream is,
+ DefaultHandler dh,
+ String systemId)
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
-
+
InputSource input = new InputSource(is);
input.setSystemId(systemId);
this.parse(input, dh);
@@ -228,20 +224,19 @@ public abstract class SAXParser {
*
* @param uri The location of the content to be parsed.
* @param hb The SAX HandlerBase to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the uri is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the uri is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
*/
-
public void parse(String uri, HandlerBase hb)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (uri == null) {
throw new IllegalArgumentException("uri cannot be null");
}
-
+
InputSource input = new InputSource(uri);
this.parse(input, hb);
}
@@ -253,20 +248,19 @@ public abstract class SAXParser {
*
* @param uri The location of the content to be parsed.
* @param dh The SAX DefaultHandler to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the uri is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the uri is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
- */
-
+ */
public void parse(String uri, DefaultHandler dh)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (uri == null) {
throw new IllegalArgumentException("uri cannot be null");
}
-
+
InputSource input = new InputSource(uri);
this.parse(input, dh);
}
@@ -279,20 +273,19 @@ public abstract class SAXParser {
*
* @param f The file containing the XML to parse
* @param hb The SAX HandlerBase to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the File object is null.
+ *
+ * @throws IllegalArgumentException If the File object is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
*/
-
public void parse(File f, HandlerBase hb)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
-
+
String uri = "file:" + f.getAbsolutePath();
if (File.separatorChar == '\\') {
uri = uri.replace('\\', '/');
@@ -307,20 +300,19 @@ public abstract class SAXParser {
*
* @param f The file containing the XML to parse
* @param dh The SAX DefaultHandler to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the File object is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the File object is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
*/
-
public void parse(File f, DefaultHandler dh)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
-
+
String uri = "file:" + f.getAbsolutePath();
if (File.separatorChar == '\\') {
uri = uri.replace('\\', '/');
@@ -338,20 +330,20 @@ public abstract class SAXParser {
*
* @param is The InputSource containing the content to be parsed.
* @param hb The SAX HandlerBase to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the InputSource is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the InputSource object
+ * is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
*/
-
public void parse(InputSource is, HandlerBase hb)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputSource cannot be null");
}
-
+
Parser parser = this.getParser();
if (hb != null) {
parser.setDocumentHandler(hb);
@@ -369,20 +361,20 @@ public abstract class SAXParser {
*
* @param is The InputSource containing the content to be parsed.
* @param dh The SAX DefaultHandler to use.
- * @exception IOException If any IO errors occur.
- * @exception IllegalArgumentException If the InputSource is null.
- * @exception SAXException If the underlying parser throws a
- * SAXException while parsing.
+ *
+ * @throws IllegalArgumentException If the InputSource object
+ * is null.
+ * @throws IOException If any IO errors occur.
+ * @throws SAXException If any SAX errors occur during processing.
+ *
* @see org.xml.sax.DocumentHandler
*/
-
public void parse(InputSource is, DefaultHandler dh)
- throws SAXException, IOException
- {
+ throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException("InputSource cannot be null");
}
-
+
XMLReader reader = this.getXMLReader();
if (dh != null) {
reader.setContentHandler(dh);
@@ -399,8 +391,9 @@ public abstract class SAXParser {
*
* @return The SAX parser that is encapsultated by the
* implementation of this class.
+ *
+ * @throws SAXException If any SAX errors occur during processing.
*/
-
public abstract org.xml.sax.Parser getParser() throws SAXException;
/**
@@ -409,6 +402,8 @@ public abstract class SAXParser {
*
* @return The XMLReader that is encapsulated by the
* implementation of this class.
+ *
+ * @throws SAXException If any SAX errors occur during processing.
*/
public abstract org.xml.sax.XMLReader getXMLReader() throws SAXException;
@@ -434,19 +429,19 @@ public abstract class SAXParser {
public abstract boolean isValidating();
/**
- * Sets the particular property in the underlying implementation of
+ * Sets the particular property in the underlying implementation of * {@link org.xml.sax.XMLReader}. * A list of the core features and properties can be found at - * http://www.megginson.com/SAX/Java/features.html + * + * http://sax.sourceforge.net/?selected=get-set.
* * @param name The name of the property to be set. * @param value The value of the property to be set. - * @exception SAXNotRecognizedException When the underlying XMLReader does - * not recognize the property name. - * - * @exception SAXNotSupportedException When the underlying XMLReader - * recognizes the property name but doesn't support the - * property. + * + * @throws SAXNotRecognizedException When the underlying XMLReader does + * not recognize the property name. + * @throws SAXNotSupportedException When the underlying XMLReader + * recognizes the property name but doesn't support the property. * * @see org.xml.sax.XMLReader#setProperty */ @@ -454,22 +449,81 @@ public abstract class SAXParser { throws SAXNotRecognizedException, SAXNotSupportedException; /** - * - * Returns the particular property requested for in the underlying - * implementation of {@link org.xml.sax.XMLReader}. + *Returns the particular property requested for in the underlying + * implementation of {@link org.xml.sax.XMLReader}.
* * @param name The name of the property to be retrieved. * @return Value of the requested property. * - * @exception SAXNotRecognizedException When the underlying XMLReader does - * not recognize the property name. - * - * @exception SAXNotSupportedException When the underlying XMLReader - * recognizes the property name but doesn't support the - * property. + * @throws SAXNotRecognizedException When the underlying XMLReader does + * not recognize the property name. + * @throws SAXNotSupportedException When the underlying XMLReader + * recognizes the property name but doesn't support the property. * * @see org.xml.sax.XMLReader#getProperty */ public abstract Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException; + + /**Get current state of canonicalization.
+ * + * @return current state canonicalization control + */ + /* + public boolean getCanonicalization() { + return canonicalState; + } + */ + + /**Get a reference to the the {@link Schema} being used by + * the XML processor.
+ * + *If no schema is being used, null is returned.
null
+ * if none in use
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public Schema getSchema() {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+ /**
+ * Get the XInclude processing mode for this parser.
+ * + * @return + * the return value of + * the {@link SAXParserFactory#isXIncludeAware()} + * when this parser was created from factory. + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @since 1.5 + * + * @see SAXParserFactory#setXIncludeAware(boolean) + */ + public boolean isXIncludeAware() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + } } diff --git a/java/external/src/javax/xml/parsers/SAXParserFactory.java b/java/external/src/javax/xml/parsers/SAXParserFactory.java index d418b7c..b0ed18f 100644 --- a/java/external/src/javax/xml/parsers/SAXParserFactory.java +++ b/java/external/src/javax/xml/parsers/SAXParserFactory.java @@ -1,88 +1,53 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, Sun Microsystems, - * Inc., http://www.sun.com. For more information on the Apache Software - * Foundation, please see
- * An implementation of the SAXParserFactory class is
- * NOT guaranteed to be thread safe. It is up to the user application
- * to make sure about the use of the SAXParserFactory from
- * more than one thread. Alternatively the application can have one instance
- * of the SAXParserFactory per thread.
- * An application can use the same instance of the factory to obtain one or
- * more instances of the SAXParser provided the instance
- * of the factory isn't being used in more than one thread at a time.
- *
+ * obtain a SAX based parser to parse XML documents.
*
- * The static newInstance method returns a new concrete
- * implementation of this class.
- *
- * @since JAXP 1.0
- * @version 1.0
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
-
public abstract class SAXParserFactory {
+ /** The default property name according to the JAXP spec */
+ private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.SAXParserFactory";
+
+ /**
+ *
Should Parsers be validating?
+ */ private boolean validating = false; - private boolean namespaceAware= false; + /** + *Should Parsers be namespace aware?
+ */ + private boolean namespaceAware = false; + + /** + *Protected constructor to force use of {@link #newInstance()}.
+ */ protected SAXParserFactory () { } @@ -104,6 +69,12 @@ public abstract class SAXParserFactory { * format and contains the fully qualified name of the * implementation class with the key being the system property defined * above. + * + * The jaxp.properties file is read only once by the JAXP implementation + * and it's values are then cached for future use. If the file does not exist + * when the first attempt is made to read from it, no further attempts are + * made to check for its existence. It is not possible to change the value + * of any property in jaxp.properties after it has been read for the first time. *SAXParserFactory it can use the factory to
* configure and obtain parser instances.
- *
+ *
+ *
+ *
+ * Setting the jaxp.debug system property will cause
+ * this method to print a lot of debug messages
+ * to System.err about what it is doing and where it is looking at.
If you have problems loading {@link DocumentBuilder}s, try:
+ *+ * java -Djaxp.debug=1 YourProgram .... + *+ * + * * @return A new instance of a SAXParserFactory. * * @exception FactoryConfigurationError if the implementation is * not available or cannot be instantiated. */ - public static SAXParserFactory newInstance() - throws FactoryConfigurationError - { + public static SAXParserFactory newInstance() { try { return (SAXParserFactory) FactoryFinder.find( /* The default property name according to the JAXP spec */ "javax.xml.parsers.SAXParserFactory", /* The fallback implementation class name */ - null); + "org.apache.xerces.jaxp.SAXParserFactoryImpl"); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); @@ -143,13 +125,14 @@ public abstract class SAXParserFactory { } /** - * Creates a new instance of a SAXParser using the currently - * configured factory parameters. + *
Creates a new instance of a SAXParser using the currently + * configured factory parameters.
* * @return A new instance of a SAXParser. * * @exception ParserConfigurationException if a parser cannot - * be created which satisfies the requested configuration. + * be created which satisfies the requested configuration. + * @exception SAXException for SAX errors. */ public abstract SAXParser newSAXParser() @@ -165,8 +148,7 @@ public abstract class SAXParserFactory { * provide support for XML namespaces; false otherwise. */ - public void setNamespaceAware(boolean awareness) - { + public void setNamespaceAware(boolean awareness) { this.namespaceAware = awareness; } @@ -174,13 +156,29 @@ public abstract class SAXParserFactory { * Specifies that the parser produced by this code will * validate documents as they are parsed. By default the value of this is * set tofalse.
+ *
+ * + * Note that "the validation" here means + * a validating + * parser as defined in the XML recommendation. + * In other words, it essentially just controls the DTD validation. + * (except the legacy two properties defined in JAXP 1.2. + * See here for more details.) + *
+ * + *+ * To use modern schema languages such as W3C XML Schema or + * RELAX NG instead of DTD, you can configure your parser to be + * a non-validating parser by leaving the {@link #setValidating(boolean)} + * method false, then use the {@link #setSchema(Schema)} + * method to associate a schema to a parser. + *
* * @param validating true if the parser produced by this code will * validate documents as they are parsed; false otherwise. */ - public void setValidating(boolean validating) - { + public void setValidating(boolean validating) { this.validating = validating; } @@ -210,19 +208,38 @@ public abstract class SAXParserFactory { /** * - * Sets the particular feature in the underlying implementation of + *Sets the particular feature in the underlying implementation of * org.xml.sax.XMLReader. * A list of the core features and properties can be found at - * http://www.megginson.com/SAX/Java/features.html + * http://www.saxproject.org/
* + *All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. + * When the feature is
+ *true: the implementation will limit XML processing to conform to implementation limits.
+ * Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+ * If XML processing is limited for security reasons, it will be reported via a call to the registered
+ * {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
+ * See {@link SAXParser} parse methods for handler specification.
+ * false, the implementation will processing XML according to the XML specifications without
+ * regard to possible implementation limits.
+ * name parameter is null.
*
* @see org.xml.sax.XMLReader#setFeature
*/
@@ -232,22 +249,182 @@ public abstract class SAXParserFactory {
/**
*
- * Returns the particular property requested for in the underlying
- * implementation of org.xml.sax.XMLReader.
+ * Returns the particular property requested for in the underlying + * implementation of org.xml.sax.XMLReader.
* * @param name The name of the property to be retrieved. + * * @return Value of the requested property. * - * @exception SAXNotRecognizedException When the underlying XMLReader does - * not recognize the property name. - * - * @exception SAXNotSupportedException When the underlying XMLReader - * recognizes the property name but doesn't support the - * property. + * @exception ParserConfigurationException if a parser cannot be created which satisfies the requested configuration. + * @exception SAXNotRecognizedException When the underlying XMLReader does not recognize the property name. + * @exception SAXNotSupportedException When the underlying XMLReader recognizes the property name but doesn't support the property. * * @see org.xml.sax.XMLReader#getProperty */ public abstract boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException; + + + + /*Get current state of canonicalization.
+ * + * @return current state canonicalization control + */ + /* + public boolean getCanonicalization() { + return canonicalState; + } + */ + + /** + * Gets the {@link Schema} object specified through + * the {@link #setSchema(Schema schema)} method. + * + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @return + * the {@link Schema} object that was last set through + * the {@link #setSchema(Schema)} method, or null + * if the method was not invoked since a {@link SAXParserFactory} + * is created. + * + * @since 1.5 + */ + public Schema getSchema() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + } + + /**Set canonicalization control to true or
+ * false.
Set the {@link Schema} to be used by parsers created + * from this factory.
+ * + *When a {@link Schema} is non-null, a parser will use a validator + * created from it to validate documents before it passes information + * down to the application.
+ * + *When warnings/errors/fatal errors are found by the validator, the parser must + * handle them as if those errors were found by the parser itself. + * In other words, if the user-specified {@link org.xml.sax.ErrorHandler} + * is set, it must receive those errors, and if not, they must be + * treated according to the implementation specific + * default error handling rules. + * + *
A validator may modify the SAX event stream (for example by + * adding default values that were missing in documents), and a parser + * is responsible to make sure that the application will receive + * those modified event stream.
+ * + *Initialy, null is set as the {@link Schema}.
This processing will take effect even if
+ * the {@link #isValidating()} method returns false.
+ *
+ *
It is an error to use
+ * the http://java.sun.com/xml/jaxp/properties/schemaSource
+ * property and/or the http://java.sun.com/xml/jaxp/properties/schemaLanguage
+ * property in conjunction with a non-null {@link Schema} object.
+ * Such configuration will cause a {@link SAXException}
+ * exception when those properties are set on a {@link SAXParser}.
+ * A parser must be able to work with any {@link Schema} + * implementation. However, parsers and schemas are allowed + * to use implementation-specific custom mechanisms + * as long as they yield the result described in the specification. + *
+ * + * @param schemaSchema to use, null to remove a schema.
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public void setSchema(Schema schema) {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+ /**
+ * Set state of XInclude processing.
+ * + *If XInclude markup is found in the document instance, should it be + * processed as specified in + * XML Inclusions (XInclude) Version 1.0.
+ * + *XInclude processing defaults to false.
true or
+ * false
+ *
+ * @throws UnsupportedOperationException
+ * For backward compatibility, when implementations for
+ * earlier versions of JAXP is used, this exception will be
+ * thrown.
+ *
+ * @since 1.5
+ */
+ public void setXIncludeAware(final boolean state) {
+ throw new UnsupportedOperationException(
+ "This parser does not support specification \""
+ + this.getClass().getPackage().getSpecificationTitle()
+ + "\" version \""
+ + this.getClass().getPackage().getSpecificationVersion()
+ + "\""
+ );
+ }
+
+ /**
+ * Get state of XInclude processing.
+ * + * @return current state of XInclude processing + * + * @throws UnsupportedOperationException + * For backward compatibility, when implementations for + * earlier versions of JAXP is used, this exception will be + * thrown. + * + * @since 1.5 + */ + public boolean isXIncludeAware() { + throw new UnsupportedOperationException( + "This parser does not support specification \"" + + this.getClass().getPackage().getSpecificationTitle() + + "\" version \"" + + this.getClass().getPackage().getSpecificationVersion() + + "\"" + ); + } } + diff --git a/java/external/src/javax/xml/parsers/SecuritySupport.java b/java/external/src/javax/xml/parsers/SecuritySupport.java new file mode 100644 index 0000000..833c47d --- /dev/null +++ b/java/external/src/javax/xml/parsers/SecuritySupport.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +// $Id: SecuritySupport.java,v 1.2.24.1 2005/03/29 23:25:08 jsuttor Exp $ + +package javax.xml.parsers; + +import java.security.*; +import java.net.*; +import java.io.*; +import java.util.*; + +/** + * This class is duplicated for each JAXP subpackage so keep it in sync. + * It is package private and therefore is not exposed as part of the JAXP + * API. + * + * Security related methods that only work on J2SE 1.2 and newer. + */ +class SecuritySupport { + + + ClassLoader getContextClassLoader() { + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ClassLoader cl = null; + try { + cl = Thread.currentThread().getContextClassLoader(); + } catch (SecurityException ex) { } + return cl; + } + }); + } + + String getSystemProperty(final String propName) { + return (String) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(propName); + } + }); + } + + FileInputStream getFileInputStream(final File file) + throws FileNotFoundException + { + try { + return (FileInputStream) + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws FileNotFoundException { + return new FileInputStream(file); + } + }); + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } + } + + InputStream getResourceAsStream(final ClassLoader cl, + final String name) + { + return (InputStream) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + InputStream ris; + if (cl == null) { + ris = ClassLoader.getSystemResourceAsStream(name); + } else { + ris = cl.getResourceAsStream(name); + } + return ris; + } + }); + } + + boolean doesFileExist(final File f) { + return ((Boolean) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(f.exists()); + } + })).booleanValue(); + } + +} diff --git a/java/external/src/javax/xml/parsers/package.html b/java/external/src/javax/xml/parsers/package.html index 54a16bb..75aa415 100644 --- a/java/external/src/javax/xml/parsers/package.html +++ b/java/external/src/javax/xml/parsers/package.html @@ -1,4 +1,7 @@ + diff --git a/java/external/src/javax/xml/transform/ErrorListener.java b/java/external/src/javax/xml/transform/ErrorListener.java index d062ad1..ff97405 100644 --- a/java/external/src/javax/xml/transform/ErrorListener.java +++ b/java/external/src/javax/xml/transform/ErrorListener.java @@ -1,75 +1,47 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *To provide customized error handling, implement this interface and - * use the setErrorListener method to register an instance of the implmentation - * with the {@link javax.xml.transform.Transformer}. The Transformer then reports - * all errors and warnings through this interface.
+ * use thesetErrorListener method to register an instance of the
+ * implmentation with the {@link javax.xml.transform.Transformer}. The
+ * Transformer then reports all errors and warnings through this
+ * interface.
*
- * If an application does not - * register an ErrorListener, errors are reported to System.err.
+ *If an application does not register its own custom
+ * ErrorListener, the default ErrorListener
+ * is used which reports all warnings and errors to System.err
+ * and does not throw any Exceptions.
+ * Applications are strongly encouraged to register and use
+ * ErrorListeners that insure proper behavior for warnings and
+ * errors.
For transformation errors, a Transformer must use this interface - * instead of throwing an exception: it is up to the application - * to decide whether to throw an exception for different types of - * errors and warnings. Note however that the Transformer is not required - * to continue with the transformation after a call to fatalError.
+ *For transformation errors, a Transformer must use this
+ * interface instead of throwing an Exception: it is up to the
+ * application to decide whether to throw an Exception for
+ * different types of errors and warnings. Note however that the
+ * Transformer is not required to continue with the transformation
+ * after a call to {@link #fatalError(TransformerException exception)}.
Transformers may use this mechanism to report XML parsing errors - * as well as transformation errors.
+ *Transformers may use this mechanism to report XML parsing
+ * errors as well as transformation errors.
Receive notification of a non-recoverable error.
* - *The transformer must continue to try and provide normal transformation - * after invoking this method. It should still be possible for the + *
The Transformer must continue to try and provide normal
+ * transformation after invoking this method. It should still be possible for the
* application to process the document through to the end if no other errors
* are encountered, but there is no guarantee that the output will be
* useable.
TransformerException.
*
* @throws javax.xml.transform.TransformerException if the application
* chooses to discontinue the transformation.
diff --git a/java/external/src/javax/xml/transform/FactoryFinder.java b/java/external/src/javax/xml/transform/FactoryFinder.java
index 6924db4..e01f212 100644
--- a/java/external/src/javax/xml/transform/FactoryFinder.java
+++ b/java/external/src/javax/xml/transform/FactoryFinder.java
@@ -1,137 +1,116 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2001, Sun Microsystems,
- * Inc., http://www.sun.com. For more information on the Apache Software
- * Foundation, please see A properties in this class are read-only.
+ *All the fields in this class are read-only.
* - * @see section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @see + * section 16 of the XSL Transformations (XSLT) W3C Recommendation */ public class OutputKeys { @@ -67,12 +33,12 @@ public class OutputKeys { * Default constructor is private on purpose. This class is * only for static variable access, and should never be constructed. */ - private OutputKeys() {} + private OutputKeys() { } /** * method = "xml" | "html" | "text" | expanded name. * - *The method attribute identifies the overall method that + *
The value of the method property identifies the overall method that * should be used for outputting the result tree. Other non-namespaced * values may be used, such as "xhtml", but, if accepted, the handling * of such values is implementation defined. If any of the method values @@ -81,7 +47,8 @@ public class OutputKeys { * or {@link javax.xml.transform.Transformer#setOutputProperties} will * throw a {@link java.lang.IllegalArgumentException}.
* - * @see section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @see + * section 16 of the XSL Transformations (XSLT) W3C Recommendation */ public static final String METHOD = "method"; @@ -94,11 +61,12 @@ public class OutputKeys { * version of XML to be used for outputting the result tree. The default * value for the xml output method is 1.0. When the output method is * "html", the version value indicates the version of the HTML. - * The default value for the html output method is 4.0, which specifies + * The default value for the xml output method is 4.0, which specifies * that the result should be output as HTML conforming to the HTML 4.0 * Recommendation [HTML]. If the output method is "text", the version * property is ignored. - * @see section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @see + * section 16 of the XSL Transformations (XSLT) W3C Recommendation */ public static final String VERSION = "version"; @@ -107,13 +75,14 @@ public class OutputKeys { * *encoding specifies the preferred character
* encoding that the Transformer should use to encode sequences of
- * characters as sequences of bytes. The value of the attribute should be
+ * characters as sequences of bytes. The value of the encoding property should be
* treated case-insensitively. The value must only contain characters in
* the range #x21 to #x7E (i.e., printable ASCII characters). The value
* should either be a charset registered with the Internet
* Assigned Numbers Authority [IANA],
* [RFC2278] or start with X-.
omit-xml-declaration specifies whether the XSLT
* processor should output an XML declaration; the value must be
* yes or no.
standalone specifies whether the Transformer
* should output a standalone document declaration; the value must be
* yes or no.
See the documentation for the {@link #DOCTYPE_SYSTEM} property * for a description of what the value of the key should be.
* - * @see section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @see + * section 16 of the XSL Transformations (XSLT) W3C Recommendation */ public static final String DOCTYPE_PUBLIC = "doctype-public"; /** * doctype-system = string. - *doctype-public specifies the public identifier
+ *
doctype-system specifies the system identifier
* to be used in the document type declaration.
If the doctype-system property is specified, the xml output method * should output a document type declaration immediately before the first @@ -157,22 +129,23 @@ public class OutputKeys { * output method should output PUBLIC followed by the public identifier * and then the system identifier; otherwise, it should output SYSTEM * followed by the system identifier. The internal subset should be empty. - * The doctype-public attribute should be ignored unless the doctype-system - * attribute is specified.
- *If the doctype-public or doctype-system attributes are specified, + * The value of the doctype-public property should be ignored unless the doctype-system + * property is specified.
+ *If the doctype-public or doctype-system properties are specified, * then the html output method should output a document type declaration * immediately before the first element. The name following <!DOCTYPE - * should be HTML or html. If the doctype-public attribute is specified, + * should be HTML or html. If the doctype-public property is specified, * then the output method should output PUBLIC followed by the specified - * public identifier; if the doctype-system attribute is also specified, + * public identifier; if the doctype-system property is also specified, * it should also output the specified system identifier following the - * public identifier. If the doctype-system attribute is specified but - * the doctype-public attribute is not specified, then the output method + * public identifier. If the doctype-system property is specified but + * the doctype-public property is not specified, then the output method * should output SYSTEM followed by the specified system identifier.
* *doctype-system specifies the system identifier
* to be used in the document type declaration.
cdata-section-elements specifies a whitespace delimited
* list of the names of elements whose text node children should be output
- * using CDATA sections.
indent specifies whether the Transformer may
* add additional whitespace when outputting the result tree; the value
* must be yes or no.
text, a charset parameter should be added
* according to the character encoding actually used by the output
* method.
- * @see section 16 of the XSL Transformations (XSLT) W3C Recommendation
+ * @see s
+ * ection 16 of the XSL Transformations (XSLT) W3C Recommendation
*/
public static final String MEDIA_TYPE = "media-type";
}
diff --git a/java/external/src/javax/xml/transform/Result.java b/java/external/src/javax/xml/transform/Result.java
index 48bd6d7..7ec9a7a 100644
--- a/java/external/src/javax/xml/transform/Result.java
+++ b/java/external/src/javax/xml/transform/Result.java
@@ -1,61 +1,28 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * An object that implements this interface contains the information + * needed to build a transformation result tree.
+ * + * @author Jeff Suttor */ public interface Result { diff --git a/java/external/src/javax/xml/transform/SecuritySupport.java b/java/external/src/javax/xml/transform/SecuritySupport.java new file mode 100644 index 0000000..5b4450f --- /dev/null +++ b/java/external/src/javax/xml/transform/SecuritySupport.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +// $Id: SecuritySupport.java,v 1.2.24.1 2005/03/29 23:32:22 jsuttor Exp $ + +package javax.xml.transform; + +import java.security.*; +import java.net.*; +import java.io.*; +import java.util.*; + +/** + * This class is duplicated for each JAXP subpackage so keep it in sync. + * It is package private and therefore is not exposed as part of the JAXP + * API. + * + * Security related methods that only work on J2SE 1.2 and newer. + */ +class SecuritySupport { + + + ClassLoader getContextClassLoader() { + return (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ClassLoader cl = null; + try { + cl = Thread.currentThread().getContextClassLoader(); + } catch (SecurityException ex) { } + return cl; + } + }); + } + + String getSystemProperty(final String propName) { + return (String) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(propName); + } + }); + } + + FileInputStream getFileInputStream(final File file) + throws FileNotFoundException + { + try { + return (FileInputStream) + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws FileNotFoundException { + return new FileInputStream(file); + } + }); + } catch (PrivilegedActionException e) { + throw (FileNotFoundException)e.getException(); + } + } + + InputStream getResourceAsStream(final ClassLoader cl, + final String name) + { + return (InputStream) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + InputStream ris; + if (cl == null) { + ris = ClassLoader.getSystemResourceAsStream(name); + } else { + ris = cl.getResourceAsStream(name); + } + return ris; + } + }); + } + + boolean doesFileExist(final File f) { + return ((Boolean) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(f.exists()); + } + })).booleanValue(); + } + +} diff --git a/java/external/src/javax/xml/transform/Source.java b/java/external/src/javax/xml/transform/Source.java index e6d66cd..a1acea1 100644 --- a/java/external/src/javax/xml/transform/Source.java +++ b/java/external/src/javax/xml/transform/Source.java @@ -1,56 +1,21 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *An instance of this class can be obtained with the An instance of this class can be obtained with the
* {@link TransformerFactory#newTransformer TransformerFactory.newTransformer}
* method. This instance may then be used to process XML from a
* variety of sources and write the transformation output to a
@@ -72,21 +36,63 @@ import java.util.Properties;
*
* A Reset this The reset Transform the XML An empty Pass a qualified name as a two-part string, the namespace URI
* enclosed in curly braces ({}), followed by the local name. If the
* name has a null URL, the String only contain the local name. An
- * application can safely check for a non-null URI by testing to see if the first
- * character of the name is a '{' character.
+ * Transformer may be used multiple times. Parameters and
* output properties are preserved across transformations.Transformer to its original configuration.Transformer is reset to the same state as when it was created with
+ * {@link TransformerFactory#newTransformer()},
+ * {@link TransformerFactory#newTransformer(Source source)} or
+ * {@link Templates#newTransformer()}.
+ * reset() is designed to allow the reuse of existing Transformers
+ * thus saving resources associated with the creation of new Transformers.Transformer is not guaranteed to have the same {@link URIResolver}
+ * or {@link ErrorListener} Objects, e.g. {@link Object#equals(Object obj)}.
+ * It is guaranteed to have a functionally equal URIResolver
+ * and ErrorListener.Source to a Result.
+ * Specific transformation behavior is determined by the settings of the
+ * TransformerFactory in effect when the
+ * Transformer was instantiated and any modifications made to
+ * the Transformer instance.Source is represented as an empty document
+ * as constructed by {@link javax.xml.parsers.DocumentBuilder#newDocument()}.
+ * The result of transforming an empty Source depends on
+ * the transformation behavior; it is not always an empty
+ * Result.Result of transforming the
+ * xmlSource.
*
* @throws TransformerException If an unrecoverable error occurs
- * during the course of the transformation.
+ * during the course of the transformation.
*/
public abstract void transform(Source xmlSource, Result outputTarget)
throws TransformerException;
@@ -97,32 +103,59 @@ public abstract class Transformer {
*
For example, if a URI and local name were obtained from an element - * defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, - * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that - * no prefix is used.
+ * defined with <xyz:foo + * xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, + * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". + * Note that no prefix is used. * - * @param name The name of the parameter, which may begin with a namespace URI - * in curly braces ({}). + * @param name The name of the parameter, which may begin with a + * namespace URI in curly braces ({}). * @param value The value object. This can be any valid Java object. It is * up to the processor to provide the proper object coersion or to simply * pass the object on for use in an extension. + * + * @throws NullPointerException If value is null. */ - public abstract void setParameter(String name, Object value); + public abstract void setParameter(String name, Object value); /** - * Get a parameter that was explicitly set with setParameter - * or setParameters. + * Get a parameter that was explicitly set with setParameter. * *This method does not return a default parameter value, which
* cannot be determined until the node context is evaluated during
* the transformation process.
*
+ * @param name of Object to get
* @return A parameter that has been set with setParameter.
*/
public abstract Object getParameter(String name);
+
+ /**
+ *
Set a list of parameters.
+ * + *Note that the list of parameters is specified as a
+ * Properties Object which limits the parameter
+ * values to Strings. Multiple calls to
+ * {@link #setParameter(String name, Object value)} should be used when the
+ * desired values are non-String Objects.
+ * The parameter names should conform as specified in
+ * {@link #setParameter(String name, Object value)}.
+ * An IllegalArgumentException is thrown if any names do not
+ * conform.
New parameters in the list are added to any existing parameters. + * If the name of a new parameter is equal to the name of an existing + * parameter as determined by {@link java.lang.Object#equals(Object obj)}, + * the existing parameter is set to the new value.
+ * + * @param params Parameters to set. + * + * @throws IllegalArgumentException If any parameter names do not conform + * to the naming rules. + */ /** * Clear all parameters set with setParameter. @@ -134,7 +167,7 @@ public abstract class Transformer { * document(). * *If the resolver argument is null, the URIResolver value will - * be cleared, and the default behavior will be used.
+ * be cleared and the transformer will no longer have a resolver. * * @param resolver An object that implements the URIResolver interface, * or null. @@ -143,7 +176,7 @@ public abstract class Transformer { /** * Get an object that will be used to resolve URIs used in - * document(), etc. + * document(). * * @return An object that implements the URIResolver interface, * or null. @@ -159,15 +192,18 @@ public abstract class Transformer { * previously set are removed, and the value will revert to the value * defined in the templates object. * - *Pass a qualified property key name as a two-part string, the namespace URI - * enclosed in curly braces ({}), followed by the local name. If the + *
Pass a qualified property key name as a two-part string, the namespace + * URI enclosed in curly braces ({}), followed by the local name. If the * name has a null URL, the String only contain the local name. An - * application can safely check for a non-null URI by testing to see if the first - * character of the name is a '{' character.
+ * application can safely check for a non-null URI by testing to see if the + * first character of the name is a '{' character. *For example, if a URI and local name were obtained from an element - * defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, - * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that - * no prefix is used.
+ * defined with <xyz:foo + * xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, + * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". + * Note that no prefix is used. + * AnIllegalArgumentException is thrown if any of the
+ * argument keys are not recognized and are not namespace qualified.
*
* @param oformat A set of output properties that will be
* used to override any of the same properties in affect
@@ -176,18 +212,16 @@ public abstract class Transformer {
* @see javax.xml.transform.OutputKeys
* @see java.util.Properties
*
- * @throws IllegalArgumentException if any of the argument keys are not
- * recognized and are not namespace qualified.
*/
- public abstract void setOutputProperties(Properties oformat)
- throws IllegalArgumentException;
+ public abstract void setOutputProperties(Properties oformat);
/**
- * Get a copy of the output properties for the transformation.
+ * Get a copy of the output properties for the transformation.
* *The properties returned should contain properties set by the user, * and properties set by the stylesheet, and these properties - * are "defaulted" by default properties specified by section 16 of the + * are "defaulted" by default properties specified by + * section 16 of the * XSL Transformations (XSLT) W3C Recommendation. The properties that * were specifically set by the user or the stylesheet should be in the base * Properties list, while the XSLT default properties that were not @@ -201,17 +235,20 @@ public abstract class Transformer { * {@link #setOutputProperties}, or in the stylesheet.
* *Note that mutation of the Properties object returned will not - * effect the properties that the transformation contains.
+ * effect the properties that the transformer contains. * *If any of the argument keys are not recognized and are not - * namespace qualified, the property will be ignored. In other words the - * behaviour is not orthogonal with setOutputProperties.
+ * namespace qualified, the property will be ignored and not returned. + * In other words the behaviour is not orthogonal with + * {@link #setOutputProperties setOutputProperties}. * - * @return A copy of the set of output properties in effect - * for the next transformation. + * @return A copy of the set of output properties in effect for + * the next transformation. * * @see javax.xml.transform.OutputKeys * @see java.util.Properties + * @see + * XSL Transformations (XSLT) Version 1.0 */ public abstract Properties getOutputProperties(); @@ -222,15 +259,16 @@ public abstract class Transformer { *Pass a qualified property name as a two-part string, the namespace URI * enclosed in curly braces ({}), followed by the local name. If the * name has a null URL, the String only contain the local name. An - * application can safely check for a non-null URI by testing to see if the first - * character of the name is a '{' character.
+ * application can safely check for a non-null URI by testing to see if the + * first character of the name is a '{' character. *For example, if a URI and local name were obtained from an element - * defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, - * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that - * no prefix is used.
+ * defined with <xyz:foo + * xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, + * then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". + * Note that no prefix is used. * - *The Properties object that was passed to {@link #setOutputProperties} won't - * be effected by calling this method.
+ *The Properties object that was passed to {@link #setOutputProperties} + * won't be effected by calling this method.
* * @param name A non-null String that specifies an output * property name, which may be namespace qualified. @@ -246,7 +284,7 @@ public abstract class Transformer { /** * Get an output property that is in effect for the - * transformation. The property specified may be a property + * transformer. The property specified may be a property * that was set with setOutputProperty, or it may be a * property specified in the stylesheet. * @@ -274,6 +312,7 @@ public abstract class Transformer { /** * Get the error event handler in effect for the transformation. + * Implementations must provide a default error listener. * * @return The current error handler, which should never be null. */ diff --git a/java/external/src/javax/xml/transform/TransformerConfigurationException.java b/java/external/src/javax/xml/transform/TransformerConfigurationException.java index a1b8911..f489cc4 100644 --- a/java/external/src/javax/xml/transform/TransformerConfigurationException.java +++ b/java/external/src/javax/xml/transform/TransformerConfigurationException.java @@ -1,56 +1,21 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Exception base cause and detail message.
*
* @param e The exception to be encapsulated in a
- * TransformerConfigurationException
+ * TransformerConfigurationException
* @param msg The detail message.
- * @param e The exception to be wrapped in a TransformerConfigurationException
*/
public TransformerConfigurationException(String msg, Throwable e) {
super(msg, e);
diff --git a/java/external/src/javax/xml/transform/TransformerException.java b/java/external/src/javax/xml/transform/TransformerException.java
index 944bbcc..ed24cfb 100644
--- a/java/external/src/javax/xml/transform/TransformerException.java
+++ b/java/external/src/javax/xml/transform/TransformerException.java
@@ -1,64 +1,26 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * A TransformerFactory instance can be used to create * {@link javax.xml.transform.Transformer} and - * {@link javax.xml.transform.Templates} objects. + * {@link javax.xml.transform.Templates} objects.
* - *The system property that determines which Factory implementation to
- * create is named "javax.xml.transform.TransformerFactory".
+ *
The system property that determines which Factory implementation
+ * to create is named "javax.xml.transform.TransformerFactory".
* This property names a concrete subclass of the
* TransformerFactory abstract class. If the property is not
* defined, a platform default is be used.
TransformerFactory class is
- * NOT guaranteed to be thread safe. It is up to the user application
- * to make sure about the use of the TransformerFactory from
- * more than one thread. Alternatively the application can have one instance
- * of the TransformerFactory per thread.
- * An application can use the same instance of the factory to obtain one or
- * more instances of a Transformer or Templates
- * provided the instance of the factory isn't being used in more than one
- * thread at a time.
+ *
+ * @author Jeff Suttor
*/
public abstract class TransformerFactory {
+
/**
* Default constructor is protected on purpose.
*/
- protected TransformerFactory() {}
+ protected TransformerFactory() { }
+
+
+ /**
+ * Get current state of canonicalization.
+ * + * @return current state canonicalization control + */ + /* + public boolean getCanonicalization() { + return canonicalState; + } + */ + + /** + *Set canonicalization control to true or
+ * false.
TransformerFactory.
@@ -97,6 +79,12 @@ public abstract class TransformerFactory {
* format and contains the fully qualified name of the
* implementation class with the key being the system property defined
* above.
+ *
+ * The jaxp.properties file is read only once by the JAXP implementation
+ * and it's values are then cached for future use. If the file does not exist
+ * when the first attempt is made to read from it, no further attempts are
+ * made to check for its existence. It is not possible to change the value
+ * of any property in jaxp.properties after it has been read for the first time.
* Process the Source into a Transformer
+ * Object. The Source is an XSLT document that
+ * conforms to
+ * XSL Transformations (XSLT) Version 1.0. Care must
+ * be taken not to use this Transformer in multiple
+ * Threads running concurrently.
+ * Different TransformerFactories can be used concurrently by
+ * different Threads.
Source of XSLT document used to create
+ * Transformer.
+ * Examples of XML Sources include
+ * {@link javax.xml.transform.dom.DOMSource DOMSource},
+ * {@link javax.xml.transform.sax.SAXSource SAXSource}, and
+ * {@link javax.xml.transform.stream.StreamSource StreamSource}.
*
- * @return A Transformer object that may be used to perform a transformation
- * in a single thread, never null (unless an {@link ErrorListener} is registered with
- * the TransformerFactory, in which case an exception error sends an error message to
- * the ErrorListener and returns null).
+ * @return A Transformer object that may be used to perform
+ * a transformation in a single Thread, never
+ * null.
*
- * @exception TransformerConfigurationException May throw this during the parse
- * when it is constructing the Templates object and fails.
+ * @throws TransformerConfigurationException Thrown if there are errors when
+ * parsing the Source or it is not possible to create a
+ * Transformer instance.
+ *
+ * @see
+ * XSL Transformations (XSLT) Version 1.0
*/
public abstract Transformer newTransformer(Source source)
throws TransformerConfigurationException;
/**
- * Create a new Transformer object that performs a copy
- * of the source to the result.
- *
- * @param source An object that holds a URI, input stream, etc.
+ * Create a new Transformer that performs a copy
+ * of the Source to the Result.
+ * i.e. the "identity transform".
Transformer instance.
*/
public abstract Transformer newTransformer()
throws TransformerConfigurationException;
@@ -183,43 +177,50 @@ public abstract class TransformerFactory {
*
* @param source An object that holds a URL, input stream, etc.
*
- * @return A Templates object capable of being used for transformation purposes,
- * never null (unless an {@link ErrorListener} is registered with
- * the TransformerFactory, in which case an exception error sends an error message to
- * the ErrorListener and returns null).
+ * @return A Templates object capable of being used for transformation
+ * purposes, never null.
*
- * @exception TransformerConfigurationException May throw this during the parse when it
- * is constructing the Templates object and fails.
+ * @exception TransformerConfigurationException May throw this during the
+ * parse when it is constructing the Templates object and fails.
*/
public abstract Templates newTemplates(Source source)
throws TransformerConfigurationException;
/**
- * Get the stylesheet specification(s) associated
- * via the xml-stylesheet processing instruction (see
- * http://www.w3.org/TR/xml-stylesheet/) with the document
- * document specified in the source parameter, and that match
- * the given criteria. Note that it is possible to return several
- * stylesheets, in which case they are applied as if they were
- * a list of imports or cascades in a single stylesheet.
+ * Get the stylesheet specification(s) associated with the
+ * XML Source document via the
+ *
+ * xml-stylesheet processing instruction that match the given criteria.
+ * Note that it is possible to return several stylesheets, in which case
+ * they are applied as if they were a list of imports or cascades in a
+ * single stylesheet.
Source Object suitable for passing
+ * to the TransformerFactory.
+ *
+ * @throws TransformerConfigurationException An Exception
+ * is thrown if an error occurings during parsing of the
+ * source.
+ *
+ * @see
+ * Associating Style Sheets with XML documents Version 1.0
*/
public abstract Source getAssociatedStylesheet(
- Source source, String media, String title, String charset)
- throws TransformerConfigurationException;
+ Source source,
+ String media,
+ String title,
+ String charset)
+ throws TransformerConfigurationException;
/**
* Set an object that is used by default during the transformation
- * to resolve URIs used in xsl:import, or xsl:include.
+ * to resolve URIs used in document(), xsl:import, or xsl:include.
*
* @param resolver An object that implements the URIResolver interface,
* or null.
@@ -236,12 +237,61 @@ public abstract class TransformerFactory {
//======= CONFIGURATION METHODS =======
+ /**
+ * Set a feature for this TransformerFactory and Transformers
+ * or Templates created by this factory.
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * An {@link TransformerConfigurationException} is thrown if this TransformerFactory or the
+ * Transformers or Templates it creates cannot support the feature.
+ * It is possible for an TransformerFactory to expose a feature value but be unable to change its state.
+ *
All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. + * When the feature is:
+ *true: the implementation will limit XML processing to conform to implementation limits
+ * and behave in a secure fashion as defined by the implementation.
+ * Examples include resolving user defined style sheets and functions.
+ * If XML processing is limited for security reasons, it will be reported via a call to the registered
+ * {@link ErrorListener#fatalError(TransformerException exception)}.
+ * See {@link #setErrorListener(ErrorListener listener)}.
+ * false: the implementation will processing XML according to the XML specifications without
+ * regard to possible implementation limits.
+ * true or false.
+ *
+ * @throws TransformerConfigurationException if this TransformerFactory
+ * or the Transformers or Templates it creates cannot support this feature.
+ * @throws NullPointerException If the name parameter is null.
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws TransformerConfigurationException;
+
/**
* Look up the value of a feature.
*
- * The feature name is any absolute URI.
- * @param name The feature name, which is an absolute URI. - * @return The current state of the feature (true or false). + *
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * false is returned if this TransformerFactory or the
+ * Transformers or Templates it creates cannot support the feature.
+ * It is possible for an TransformerFactory to expose a feature value but be unable to change its state.
+ *
true or false.
+ *
+ * @throws NullPointerException If the name parameter is null.
*/
public abstract boolean getFeature(String name);
@@ -249,36 +299,35 @@ public abstract class TransformerFactory {
* Allows the user to set specific attributes on the underlying
* implementation. An attribute in this context is defined to
* be an option that the implementation provides.
+ * An IllegalArgumentException is thrown if the underlying
+ * implementation doesn't recognize the attribute.
*
* @param name The name of the attribute.
* @param value The value of the attribute.
- * @throws IllegalArgumentException thrown if the underlying
- * implementation doesn't recognize the attribute.
*/
- public abstract void setAttribute(String name, Object value)
- throws IllegalArgumentException;
+ public abstract void setAttribute(String name, Object value);
/**
* Allows the user to retrieve specific attributes on the underlying
* implementation.
+ * An IllegalArgumentException is thrown if the underlying
+ * implementation doesn't recognize the attribute.
+ *
* @param name The name of the attribute.
* @return value The value of the attribute.
- * @throws IllegalArgumentException thrown if the underlying
- * implementation doesn't recognize the attribute.
*/
- public abstract Object getAttribute(String name)
- throws IllegalArgumentException;
+ public abstract Object getAttribute(String name);
/**
* Set the error event listener for the TransformerFactory, which
* is used for the processing of transformation instructions,
* and not for the transformation itself.
+ * An IllegalArgumentException is thrown if the
+ * ErrorListener listener is null.
*
* @param listener The new error listener.
- * @throws IllegalArgumentException if listener is null.
*/
- public abstract void setErrorListener(ErrorListener listener)
- throws IllegalArgumentException;
+ public abstract void setErrorListener(ErrorListener listener);
/**
* Get the error event handler for the TransformerFactory.
@@ -286,4 +335,6 @@ public abstract class TransformerFactory {
* @return The current error handler, which should never be null.
*/
public abstract ErrorListener getErrorListener();
+
}
+
diff --git a/java/external/src/javax/xml/transform/TransformerFactoryConfigurationError.java b/java/external/src/javax/xml/transform/TransformerFactoryConfigurationError.java
index cc1df78..1e9bb67 100644
--- a/java/external/src/javax/xml/transform/TransformerFactoryConfigurationError.java
+++ b/java/external/src/javax/xml/transform/TransformerFactoryConfigurationError.java
@@ -1,56 +1,21 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * Exception for the
+ * TransformerFactoryConfigurationError.
+ */
private Exception exception;
/**
@@ -108,7 +77,6 @@ public class TransformerFactoryConfigurationError extends Error {
* @param e The exception to be encapsulated in a
* TransformerFactoryConfigurationError
* @param msg The detail message.
- * @param e The exception to be wrapped in a TransformerFactoryConfigurationError
*/
public TransformerFactoryConfigurationError(Exception e, String msg) {
diff --git a/java/external/src/javax/xml/transform/URIResolver.java b/java/external/src/javax/xml/transform/URIResolver.java
index bdad104..3864914 100644
--- a/java/external/src/javax/xml/transform/URIResolver.java
+++ b/java/external/src/javax/xml/transform/URIResolver.java
@@ -1,56 +1,21 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * Acts as a holder for a transformation result tree in the form of a Document Object Model (DOM) tree.
+ * + *If no output DOM source is set, the transformation will create a Document node as the holder for the result of the transformation, + * which may be retrieved with {@link #getNode()}.
+ * + * @author Jeff Suttor + * @version $Revision$, $Date$ */ public class DOMResult implements Result { - /** If {@link javax.xml.transform.TransformerFactory#getFeature} - * returns true when passed this value as an argument, - * the Transformer supports Result output of this type. + /**If {@link javax.xml.transform.TransformerFactory#getFeature}
+ * returns true when passed this value as an argument,
+ * the Transformer supports Result output of this type.
Zero-argument default constructor.
+ * + *node,
+ * siblingNode and
+ * systemId
+ * will be set to null.
Use a DOM node to create a new output target.
+ * + *In practice, the node should be + * a {@link org.w3c.dom.Document} node, + * a {@link org.w3c.dom.DocumentFragment} node, or + * a {@link org.w3c.dom.Element} node. + * In other words, a node that accepts children.
* - * @param n The DOM node that will contain the result tree. + *siblingNode and
+ * systemId
+ * will be set to null.
Use a DOM node to create a new output target with the specified System ID.
+ * + *
In practice, the node should be + * a {@link org.w3c.dom.Document} node, + * a {@link org.w3c.dom.DocumentFragment} node, or + * a {@link org.w3c.dom.Element} node. + * In other words, a node that accepts children.
* + *siblingNode will be set to null.
Use a DOM node to create a new output target specifying the child node where the result nodes should be inserted before.
+ * + *In practice, node and nextSibling should be
+ * a {@link org.w3c.dom.Document} node,
+ * a {@link org.w3c.dom.DocumentFragment} node, or
+ * a {@link org.w3c.dom.Element} node.
+ * In other words, a node that accepts children.
Use nextSibling to specify the child node
+ * where the result nodes should be inserted before.
+ * If nextSibling is not a sibling of node,
+ * then an IllegalArgumentException is thrown.
+ * If node is null and nextSibling is not null,
+ * then an IllegalArgumentException is thrown.
+ * If nextSibling is null,
+ * then the behavior is the same as calling {@link #DOMResult(Node node)},
+ * i.e. append the result nodes as the last child of the specified node.
systemId will be set to null.
nextSibling is not a sibling of node.
+ * @throws IllegalArgumentException If node is null and nextSibling is not null.
+ *
+ * @since 1.5
+ */
+ public DOMResult(Node node, Node nextSibling) {
+
+ // does the corrent parent/child relationship exist?
+ if (nextSibling != null) {
+ // cannot be a sibling of a null node
+ if (node == null) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is contained by the \"null\" node.");
+ }
+
+ // nextSibling contained by node?
+ if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
+ }
+ }
+
+ setNode(node);
+ setNextSibling(nextSibling);
+ setSystemId(null);
+ }
+
+ /**
+ * Use a DOM node to create a new output target specifying the child node where the result nodes should be inserted before and + * the specified System ID.
+ * + *In practice, node and nextSibling should be
+ * a {@link org.w3c.dom.Document} node,
* a {@link org.w3c.dom.DocumentFragment} node, or a
- * {@link org.w3c.dom.Element} node. In other words, a node
- * that accepts children.
+ * {@link org.w3c.dom.Element} node.
+ * In other words, a node that accepts children.
Use nextSibling to specify the child node
+ * where the result nodes should be inserted before.
+ * If nextSibling is not a sibling of node,
+ * then an IllegalArgumentException is thrown.
+ * If node is null and nextSibling is not null,
+ * then an IllegalArgumentException is thrown.
+ * If nextSibling is null,
+ * then the behavior is the same as calling {@link #DOMResult(Node node, String systemId)},
+ * i.e. append the result nodes as the last child of the specified node and use the specified System ID.
nextSibling is not a sibling of node.
+ * @throws IllegalArgumentException If node is null and nextSibling is not null.
+ *
+ * @since 1.5
+ */
+ public DOMResult(Node node, Node nextSibling, String systemId) {
+
+ // does the corrent parent/child relationship exist?
+ if (nextSibling != null) {
+ // cannot be a sibling of a null node
+ if (node == null) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is contained by the \"null\" node.");
+ }
+
+ // nextSibling contained by node?
+ if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
+ }
+ }
+
+ setNode(node);
+ setNextSibling(nextSibling);
+ setSystemId(systemId);
+ }
+
+ /**
+ * Set the node that will contain the result DOM tree.
+ * + *
In practice, the node should be + * a {@link org.w3c.dom.Document} node, + * a {@link org.w3c.dom.DocumentFragment} node, or + * a {@link org.w3c.dom.Element} node. + * In other words, a node that accepts children.
+ * + *An IllegalStateException is thrown if nextSibling is not null and
+ * node is not a parent of nextSibling.
+ * An IllegalStateException is thrown if node is null and
+ * nextSibling is not null.
nextSibling is not null and
+ * nextSibling is not a child of node.
+ * @throws IllegalStateException If node is null and
+ * nextSibling is not null.
*/
public void setNode(Node node) {
+ // does the corrent parent/child relationship exist?
+ if (nextSibling != null) {
+ // cannot be a sibling of a null node
+ if (node == null) {
+ throw new IllegalStateException("Cannot create a DOMResult when the nextSibling is contained by the \"null\" node.");
+ }
+
+ // nextSibling contained by node?
+ if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
+ }
+ }
+
this.node = node;
}
/**
- * Get the node that will contain the result DOM tree.
- * If no node was set via setNode, the node will be
- * set by the transformation, and may be obtained from
- * this method once the transformation is complete.
+ * Get the node that will contain the result DOM tree.
+ * + *If no node was set via
+ * {@link #DOMResult(Node node)},
+ * {@link #DOMResult(Node node, String systeId)},
+ * {@link #DOMResult(Node node, Node nextSibling)},
+ * {@link #DOMResult(Node node, Node nextSibling, String systemId)} or
+ * {@link #setNode(Node node)},
+ * then the node will be set by the transformation, and may be obtained from this method once the transformation is complete.
+ * Calling this method before the transformation will return null.
Set the child node before which the result nodes will be inserted.
+ * + *Use nextSibling to specify the child node
+ * before which the result nodes should be inserted.
+ * If nextSibling is not a descendant of node,
+ * then an IllegalArgumentException is thrown.
+ * If node is null and nextSibling is not null,
+ * then an IllegalStateException is thrown.
+ * If nextSibling is null,
+ * then the behavior is the same as calling {@link #DOMResult(Node node)},
+ * i.e. append the result nodes as the last child of the specified node.
nextSibling is not a descendant of node.
+ * @throws IllegalStateException If node is null and nextSibling is not null.
+ *
+ * @since 1.5
+ */
+ public void setNextSibling(Node nextSibling) {
+
+ // does the corrent parent/child relationship exist?
+ if (nextSibling != null) {
+ // cannot be a sibling of a null node
+ if (node == null) {
+ throw new IllegalStateException("Cannot create a DOMResult when the nextSibling is contained by the \"null\" node.");
+ }
+
+ // nextSibling contained by node?
+ if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) {
+ throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
+ }
+ }
+
+ this.nextSibling = nextSibling;
+ }
+
+ /**
+ * Get the child node before which the result nodes will be inserted.
+ * + *If no node was set via
+ * {@link #DOMResult(Node node, Node nextSibling)},
+ * {@link #DOMResult(Node node, Node nextSibling, String systemId)} or
+ * {@link #setNextSibling(Node nextSibling)},
+ * then null will be returned.
Set the systemId that may be used in association with the node.
* * @param systemId The system identifier as a URI string. */ @@ -146,10 +312,15 @@ public class DOMResult implements Result { } /** - * Get the system identifier that was set with setSystemId. + *Get the System Identifier.
+ * + *If no System ID was set via
+ * {@link #DOMResult(Node node, String systemId)},
+ * {@link #DOMResult(Node node, Node nextSibling, String systemId)} or
+ * {@link #setSystemId(String systemId)},
+ * then null will be returned.
The node to which the transformation will be appended.
*/ - private Node node; + private Node node = null; /** - * The systemID that may be used in association - * with the node. + *The child node before which the result nodes will be inserted.
+ * + * @since 1.5 */ - private String systemId; + private Node nextSibling = null; + + /** + *The System ID that may be used in association with the node.
+ */ + private String systemId = null; } diff --git a/java/external/src/javax/xml/transform/dom/DOMSource.java b/java/external/src/javax/xml/transform/dom/DOMSource.java index 296b56f..5e36807 100644 --- a/java/external/src/javax/xml/transform/dom/DOMSource.java +++ b/java/external/src/javax/xml/transform/dom/DOMSource.java @@ -1,71 +1,53 @@ /* - * The Apache Software License, Version 1.1 + * 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 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "Apache Software Foundation" must not be used to endorse or - * promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *Acts as a holder for a transformation Source tree in the + * form of a Document Object Model (DOM) tree.
+ * + *Note that XSLT requires namespace support. Attempting to transform a DOM + * that was not contructed with a namespace-aware parser may result in errors. + * Parsers can be made namespace aware by calling + * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.
+ * + * @author Jeff Suttor + * @version $Revision$, $Date$ * @see Document Object Model (DOM) Level 2 Specification */ public class DOMSource implements Source { + /** + *Node to serve as DOM source.
The base ID (URL or system ID) from where URLs + * will be resolved.
+ */ + private String systemID; + /** If {@link javax.xml.transform.TransformerFactory#getFeature} * returns true when passed this value as an argument, * the Transformer supports Source input of this type. @@ -74,12 +56,15 @@ public class DOMSource implements Source { "http://javax.xml.transform.dom.DOMSource/feature"; /** - * Zero-argument default constructor. If this is used, and - * no DOM source is set, then the Transformer will - * create an empty source Document using - * {@link javax.xml.parsers.DocumentBuilder#newDocument}. + *Zero-argument default constructor. If this constructor is used, and
+ * no DOM source is set using {@link #setNode(Node node)} , then the
+ * Transformer will
+ * create an empty source {@link org.w3c.dom.Document} using
+ * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.
-SAX
-
Simple API for XML, specifically referring to the
- SAX 2.0
- release.
+ SAX
+ Simple API for XML, specifically referring to the SAX 2.0.2 release.
+
This package defines the generic APIs for processing transformation - instructions, and performing a transformation from source to result. These - interfaces have no dependencies on SAX or the DOM standard, and try to make as - few assumptions as possible about the details of the source and result of a - transformation. It achieves this by defining - {@link javax.xml.transform.Source} and - {@link javax.xml.transform.Result} interfaces.
-To define concrete classes for the user, the API defines specializations - of the interfaces found at the root level. These interfaces are found in - {@link javax.xml.transform.sax}, {@link javax.xml.transform.dom}, - and {@link javax.xml.transform.stream}.
- -The API allows a concrete - {@link javax.xml.transform.TransformerFactory} object to be created from - the static function - {@link javax.xml.transform.TransformerFactory#newInstance}. - - -
This API defines two interface objects called - {@link javax.xml.transform.Source} and - {@link javax.xml.transform.Result}. In order to pass Source and Result - objects to the interfaces, concrete classes must be used. - Three concrete representations are defined for each of these - objects: - {@link javax.xml.transform.stream.StreamSource} and - {@link javax.xml.transform.stream.StreamResult}, - {@link javax.xml.transform.sax.SAXSource} and - {@link javax.xml.transform.sax.SAXResult}, and - {@link javax.xml.transform.dom.DOMSource} and - {@link javax.xml.transform.dom.DOMResult}. Each of these objects defines - a FEATURE string (which is i the form of a URL), which can be passed into - {@link javax.xml.transform.TransformerFactory#getFeature} to see if the - given type of Source or Result object is supported. For instance, to test if a - DOMSource and a StreamResult is supported, you can apply the following - test.
- -
- TransformerFactory tfactory = TransformerFactory.newInstance();
+instructions, and performing a transformation from source to result. These
+interfaces have no dependencies on SAX or the DOM standard, and try to make as
+few assumptions as possible about the details of the source and result of a
+transformation. It achieves this by defining
+{@link javax.xml.transform.Source} and
+{@link javax.xml.transform.Result} interfaces.
+
- if (tfactory.getFeature(DOMSource.FEATURE) && tfactory.getFeature(StreamResult.FEATURE))
- {
- ...
- }
+To define concrete classes for the user, the API defines specializations
+of the interfaces found at the root level. These interfaces are found in
+{@link javax.xml.transform.sax}, {@link javax.xml.transform.dom},
+and {@link javax.xml.transform.stream}.
+
+
+
+Creating Objects
+
+The API allows a concrete
+{@link javax.xml.transform.TransformerFactory} object to be created from
+the static function
+{@link javax.xml.transform.TransformerFactory#newInstance}.
+
+
+
+Specification of Inputs and Outputs
+
+This API defines two interface objects called
+{@link javax.xml.transform.Source} and
+{@link javax.xml.transform.Result}. In order to pass Source and Result
+objects to the interfaces, concrete classes must be used.
+Three concrete representations are defined for each of these
+objects:
+{@link javax.xml.transform.stream.StreamSource} and
+{@link javax.xml.transform.stream.StreamResult},
+{@link javax.xml.transform.sax.SAXSource} and
+{@link javax.xml.transform.sax.SAXResult}, and
+{@link javax.xml.transform.dom.DOMSource} and
+{@link javax.xml.transform.dom.DOMResult}. Each of these objects defines
+a FEATURE string (which is i the form of a URL), which can be passed into
+{@link javax.xml.transform.TransformerFactory#getFeature} to see if the
+given type of Source or Result object is supported. For instance, to test if a
+DOMSource and a StreamResult is supported, you can apply the following
+test.
+
+
+
+
+TransformerFactory tfactory = TransformerFactory.newInstance();
+if (tfactory.getFeature(DOMSource.FEATURE) && tfactory.getFeature(StreamResult.FEATURE)) {
+...
+}
-
-
+
+
+
Qualified Name Representation
-
-
-Namespaces
- present something of a problem area when dealing with XML objects. Qualified
- Names appear in XML markup as prefixed names. But the prefixes themselves do
- not hold identity. Rather, it is the URIs that they contextually map to that
- hold the identity. Therefore, when passing a Qualified Name like "xyz:foo"
- among Java programs, one must provide a means to map "xyz" to a namespace.
-
-
+
+Namespaces
+present something of a problem area when dealing with XML objects. Qualified
+Names appear in XML markup as prefixed names. But the prefixes themselves do
+not hold identity. Rather, it is the URIs that they contextually map to that
+hold the identity. Therefore, when passing a Qualified Name like "xyz:foo"
+among Java programs, one must provide a means to map "xyz" to a namespace.
+
+
One solution has been to create a "QName" object that holds the
- namespace URI, as well as the prefix and local name, but this is not always an
- optimal solution, as when, for example, you want to use unique strings as keys
- in a dictionary object. Not having a string representation also makes it
- difficult to specify a namespaced identity outside the context of an XML
- document.
-
-In order to pass namespaced values to transformations, for instance
- as a set of properties to the Serializer, this specification defines that a
- String "qname" object parameter be passed as two-part string, the namespace URI
- enclosed in curly braces ({}), followed by the local name. If the qname has a
- null URI, then the String object only contains the local name. An application
- can safely check for a non-null URI by testing to see if the first character of
- the name is a '{' character.
-
+namespace URI, as well as the prefix and local name, but this is not always an
+optimal solution, as when, for example, you want to use unique strings as keys
+in a dictionary object. Not having a string representation also makes it
+difficult to specify a namespaced identity outside the context of an XML
+document.
+
+
+In order to pass namespaced values to transformations,
+for
+instance when setting a property or a parameter on a
+{@link javax.xml.transform.Transformer} object,
+this specification defines that a
+String "qname" object parameter be passed as two-part string, the namespace URI
+enclosed in curly braces ({}), followed by the local name. If the qname has a
+null URI, then the String object only contains the local name. An application
+can safely check for a non-null URI by testing to see if the first character of
+the name is a '{' character.
+
+
For example, if a URI and local name were obtained from an element
- defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>,
- then the Qualified Name would be "{http://xyz.foo.com/yada/baz.html}foo".
- Note that the prefix is lost.
-
-
+defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>,
+then the Qualified Name would be "{http://xyz.foo.com/yada/baz.html}foo".
+Note that the prefix is lost.
+
+
+
Result Tree Serialization
-
+
Serialization of the result tree to a stream can be controlled with
- the {@link javax.xml.transform.Transformer#setOutputProperties} and the
- {@link javax.xml.transform.Transformer#setOutputProperty} methods.
- Strings that match the XSLT
- specification for xsl:output attributes can be referenced from the
- {@link javax.xml.transform.OutputKeys} class. Other strings can be
- specified as well. If the transformer does not recognize an output key, a
- {@link java.lang.IllegalArgumentException} is thrown, unless the
- key name is namespace qualified. Output key names that are
- qualified by a namespace are ignored or passed on to the serializer
- mechanism.
-
+the {@link javax.xml.transform.Transformer#setOutputProperties} and the
+{@link javax.xml.transform.Transformer#setOutputProperty} methods.
+These properties only apply to stream results, they have no effect when
+the result is a DOM tree or SAX event stream.
+
+Strings that match the XSLT
+specification for xsl:output attributes can be referenced from the
+{@link javax.xml.transform.OutputKeys} class. Other strings can be
+specified as well.
+If the transformer does not recognize an output key, a
+{@link java.lang.IllegalArgumentException} is thrown, unless the
+key name is namespace qualified. Output key names
+that are namespace qualified are always allowed, although they may be
+ignored by some implementations.
+
If all that is desired is the simple identity transformation of a
- source to a result, then {@link javax.xml.transform.TransformerFactory}
- provides a
- {@link javax.xml.transform.TransformerFactory#newTransformer()} method
- with no arguments. This method creates a Transformer that effectively copies
- the source to the result. This method may be used to create a DOM from SAX
- events or to create an XML or HTML stream from a DOM or SAX events.
-
-
-
+source to a result, then {@link javax.xml.transform.TransformerFactory}
+provides a
+{@link javax.xml.transform.TransformerFactory#newTransformer()} method
+with no arguments. This method creates a Transformer that effectively copies
+the source to the result. This method may be used to create a DOM from SAX
+events or to create an XML or HTML stream from a DOM or SAX events.
+
Exceptions and Error Reporting
-
+
The transformation API throw three types of specialized exceptions. A
- {@link javax.xml.transform.TransformerFactoryConfigurationError} is parallel to
- the {@link javax.xml.parsers.FactoryConfigurationError}, and is thrown
- when a configuration problem with the TransformerFactory exists. This error
- will typically be thrown when the transformation factory class specified with
- the "javax.xml.transform.TransformerFactory" system property cannot be found or
- instantiated.
-
+{@link javax.xml.transform.TransformerFactoryConfigurationError} is parallel to
+the {@link javax.xml.parsers.FactoryConfigurationError}, and is thrown
+when a configuration problem with the TransformerFactory exists. This error
+will typically be thrown when the transformation factory class specified with
+the "javax.xml.transform.TransformerFactory" system property cannot be found or
+instantiated.
+
A {@link javax.xml.transform.TransformerConfigurationException}
- may be thrown if for any reason a Transformer can not be created. A
- TransformerConfigurationException may be thrown if there is a syntax error in
- the transformation instructions, for example when
- {@link javax.xml.transform.TransformerFactory#newTransformer} is
- called.
-
+may be thrown if for any reason a Transformer can not be created. A
+TransformerConfigurationException may be thrown if there is a syntax error in
+the transformation instructions, for example when
+{@link javax.xml.transform.TransformerFactory#newTransformer} is
+called.
+
{@link javax.xml.transform.TransformerException} is a general
- exception that occurs during the course of a transformation. A transformer
- exception may wrap another exception, and if any of the
- {@link javax.xml.transform.TransformerException#printStackTrace()}
- methods are called on it, it will produce a list of stack dumps, starting from
- the most recent. The transformer exception also provides a
- {@link javax.xml.transform.SourceLocator} object which indicates where
- in the source tree or transformation instructions the error occurred.
- {@link javax.xml.transform.TransformerException#getMessageAndLocation()}
- may be called to get an error message with location info, and
- {@link javax.xml.transform.TransformerException#getLocationAsString()}
- may be called to get just the location string.
-
-Transformation warnings and errors are normally first sent to a
- {@link javax.xml.transform.ErrorListener}, at which point the
- implementor may decide to report the error or warning, and may decide to throw
- an exception for a non-fatal error. The error listener may be set via
- {@link javax.xml.transform.TransformerFactory#setErrorListener} for
- reporting errors that have to do with syntax errors in the transformation
- instructions, or via
- {@link javax.xml.transform.Transformer#setErrorListener} to report
- errors that occur during the transformation. The error listener on both objects
- should always be valid and non-null, whether set by the user or a default
- implementation provided by the processor.
-
-
+exception that occurs during the course of a transformation. A transformer
+exception may wrap another exception, and if any of the
+{@link javax.xml.transform.TransformerException#printStackTrace()}
+methods are called on it, it will produce a list of stack dumps, starting from
+the most recent. The transformer exception also provides a
+{@link javax.xml.transform.SourceLocator} object which indicates where
+in the source tree or transformation instructions the error occurred.
+{@link javax.xml.transform.TransformerException#getMessageAndLocation()}
+may be called to get an error message with location info, and
+{@link javax.xml.transform.TransformerException#getLocationAsString()}
+may be called to get just the location string.
+
+Transformation warnings and errors are sent to an
+{@link javax.xml.transform.ErrorListener}, at which point the
+application may decide to report the error or warning, and may decide to throw
+an Exception for a non-fatal error. The ErrorListener may be set via
+{@link javax.xml.transform.TransformerFactory#setErrorListener} for
+reporting errors that have to do with syntax errors in the transformation
+instructions, or via
+{@link javax.xml.transform.Transformer#setErrorListener} to report
+errors that occur during the transformation. The ErrorListener on both objects
+will always be valid and non-null, whether set by the application or a default
+implementation provided by the processor.
+The default implementation provided by the processor will report all warnings and errors to System.err
+and does not throw any Exceptions.
+Applications are strongly encouraged to register and use
+ErrorListeners that insure proper behavior for warnings and
+errors.
+
+
+
Resolution of URIs within a transformation
-
+
The API provides a way for URIs referenced from within the stylesheet
- instructions or within the transformation to be resolved by the calling
- application. This can be done by creating a class that implements the
- {@link javax.xml.transform.URIResolver} interface, with its one method,
- {@link javax.xml.transform.URIResolver#resolve}, and use this class to
- set the URI resolution for the transformation instructions or transformation
- with {@link javax.xml.transform.TransformerFactory#setURIResolver} or
- {@link javax.xml.transform.Transformer#setURIResolver}. The
- URIResolver.resolve method takes two String arguments, the URI found in the
- stylesheet instructions or built as part of the transformation process, and the
- base URI in effect when the URI passed as the first argument was encountered.
- The returned {@link javax.xml.transform.Source} object must be usable by
- the transformer, as specified in its implemented features.
-
+instructions or within the transformation to be resolved by the calling
+application. This can be done by creating a class that implements the
+{@link javax.xml.transform.URIResolver} interface, with its one method,
+{@link javax.xml.transform.URIResolver#resolve}, and use this class to
+set the URI resolution for the transformation instructions or transformation
+with {@link javax.xml.transform.TransformerFactory#setURIResolver} or
+{@link javax.xml.transform.Transformer#setURIResolver}. The
+URIResolver.resolve method takes two String arguments, the URI found in the
+stylesheet instructions or built as part of the transformation process, and the
+base URI
+against which the first argument will be made absolute if the
+absolute URI is required.
+The returned {@link javax.xml.transform.Source} object must be usable by
+the transformer, as specified in its implemented features.
+
diff --git a/java/external/src/javax/xml/transform/sax/SAXResult.java b/java/external/src/javax/xml/transform/sax/SAXResult.java
index a946c8b..b3739c2 100644
--- a/java/external/src/javax/xml/transform/sax/SAXResult.java
+++ b/java/external/src/javax/xml/transform/sax/SAXResult.java
@@ -1,66 +1,32 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.sax;
-import javax.xml.transform.*;
+import javax.xml.transform.Result;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.LexicalHandler;
-
/**
- * Acts as an holder for a transformation Result.
+ * Acts as an holder for a transformation Result.
+ *
+ * @author Jeff Suttor
*/
public class SAXResult implements Result {
@@ -75,7 +41,8 @@ public class SAXResult implements Result {
/**
* Zero-argument default constructor.
*/
- public SAXResult() {}
+ public SAXResult() {
+ }
/**
* Create a SAXResult that targets a SAX2 {@link org.xml.sax.ContentHandler}.
diff --git a/java/external/src/javax/xml/transform/sax/SAXSource.java b/java/external/src/javax/xml/transform/sax/SAXSource.java
index 02af4be..0a4e194 100644
--- a/java/external/src/javax/xml/transform/sax/SAXSource.java
+++ b/java/external/src/javax/xml/transform/sax/SAXSource.java
@@ -1,67 +1,40 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.sax;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
-
+import org.xml.sax.XMLReader;
/**
- * Acts as an holder for SAX-style Source.
+ * Acts as an holder for SAX-style Source.
+ *
+ * Note that XSLT requires namespace support. Attempting to transform an
+ * input source that is not
+ * generated with a namespace-aware parser may result in errors.
+ * Parsers can be made namespace aware by calling the
+ * {@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method.
+ *
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
public class SAXSource implements Source {
@@ -74,12 +47,16 @@ public class SAXSource implements Source {
"http://javax.xml.transform.sax.SAXSource/feature";
/**
- * Zero-argument default constructor. If this constructor
- * is used, and no other method is called, the
- * {@link javax.xml.transform.Transformer}
- * assumes an empty input tree, with a default root node.
+ * Zero-argument default constructor. If this constructor is used, and
+ * no SAX source is set using
+ * {@link #setInputSource(InputSource inputSource)} , then the
+ * Transformer will
+ * create an empty source {@link org.xml.sax.InputSource} using
+ * {@link org.xml.sax.InputSource#InputSource() new InputSource()}.
+ *
+ * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
*/
- public SAXSource() {}
+ public SAXSource() { }
/**
* Create a SAXSource, using an {@link org.xml.sax.XMLReader}
@@ -173,26 +150,33 @@ public class SAXSource implements Source {
}
/**
- * Get the base ID (URI or system ID) from where URIs
- * will be resolved.
+ * Get the base ID (URI or system ID) from where URIs
+ * will be resolved.
*
- * @return Base URL for the Source, or null.
+ * @return Base URL for the Source, or null.
*/
public String getSystemId() {
- return (null != inputSource)
- ? inputSource.getSystemId()
- : null;
+ if (inputSource == null) {
+ return null;
+ } else {
+ return inputSource.getSystemId();
+ }
}
- /** The XMLReader to be used for the source tree input. May be null. */
+ /**
+ * The XMLReader to be used for the source tree input. May be null.
+ */
private XMLReader reader;
- /** The SAX InputSource to be used for the source tree input. Should not be null. */
+ /**
+ * The SAX InputSource to be used for the source tree input.
+ * Should not be null.
+ */
private InputSource inputSource;
/**
- * Attempt to obtain a SAX InputSource object from a TrAX Source
+ * Attempt to obtain a SAX InputSource object from a Source
* object.
*
* @param source Must be a non-null Source reference.
diff --git a/java/external/src/javax/xml/transform/sax/SAXTransformerFactory.java b/java/external/src/javax/xml/transform/sax/SAXTransformerFactory.java
index ba9898e..2b6c7ba 100644
--- a/java/external/src/javax/xml/transform/sax/SAXTransformerFactory.java
+++ b/java/external/src/javax/xml/transform/sax/SAXTransformerFactory.java
@@ -1,63 +1,27 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.sax;
import javax.xml.transform.*;
import org.xml.sax.XMLFilter;
-
/**
* This class extends TransformerFactory to provide SAX-specific
* factory methods. It provides two types of ContentHandlers,
diff --git a/java/external/src/javax/xml/transform/sax/TemplatesHandler.java b/java/external/src/javax/xml/transform/sax/TemplatesHandler.java
index 052643e..a90778a 100644
--- a/java/external/src/javax/xml/transform/sax/TemplatesHandler.java
+++ b/java/external/src/javax/xml/transform/sax/TemplatesHandler.java
@@ -1,63 +1,27 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.sax;
import javax.xml.transform.*;
import org.xml.sax.ContentHandler;
-
/**
* A SAX ContentHandler that may be used to process SAX
* parse events (parsing transformation instructions) into a Templates object.
@@ -84,7 +48,7 @@ public interface TemplatesHandler extends ContentHandler {
* resolve relative URIs in the stylesheet. This must be
* called before the startDocument event.
*
- * @param baseID Base URI for this stylesheet.
+ * @param systemID Base URI for this stylesheet.
*/
public void setSystemId(String systemID);
diff --git a/java/external/src/javax/xml/transform/sax/TransformerHandler.java b/java/external/src/javax/xml/transform/sax/TransformerHandler.java
index 1b0ef6f..b4505a6 100644
--- a/java/external/src/javax/xml/transform/sax/TransformerHandler.java
+++ b/java/external/src/javax/xml/transform/sax/TransformerHandler.java
@@ -1,65 +1,29 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.sax;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.DTDHandler;
-
+import org.xml.sax.ext.LexicalHandler;
/**
* A TransformerHandler
@@ -70,10 +34,11 @@ public interface TransformerHandler
extends ContentHandler, LexicalHandler, DTDHandler {
/**
- * Enables the user of the TransformerHandler to set the
- * to set the Result for the transformation.
+ * Set the Result associated with this
+ * TransformerHandler to be used for the transformation.
*
- * @param result A Result instance, should not be null.
+ * @param result A Result instance, should not be
+ * null.
*
* @throws IllegalArgumentException if result is invalid for some reason.
*/
@@ -94,8 +59,11 @@ public interface TransformerHandler
public String getSystemId();
/**
- * Get the Transformer associated with this handler, which
- * is needed in order to set parameters and output properties.
+ * Get the Transformer associated with this handler, which
+ * is needed in order to set parameters and output properties.
+ *
+ * @return Transformer associated with this
+ * TransformerHandler.
*/
public Transformer getTransformer();
}
diff --git a/java/external/src/javax/xml/transform/stream/StreamResult.java b/java/external/src/javax/xml/transform/stream/StreamResult.java
index c854460..b99dc67 100644
--- a/java/external/src/javax/xml/transform/stream/StreamResult.java
+++ b/java/external/src/javax/xml/transform/stream/StreamResult.java
@@ -1,69 +1,35 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.stream;
-import javax.xml.transform.*;
+import javax.xml.transform.Result;
+import java.io.File;
import java.io.OutputStream;
import java.io.Writer;
-import java.io.File;
-
+import java.net.MalformedURLException;
/**
- * Acts as an holder for a transformation result,
- * which may be XML, plain Text, HTML, or some other form of markup.
+ * Acts as an holder for a transformation result,
+ * which may be XML, plain Text, HTML, or some other form of markup.
*
+ * @author Jeff Suttor
*/
public class StreamResult implements Result {
@@ -77,7 +43,8 @@ public class StreamResult implements Result {
/**
* Zero-argument default constructor.
*/
- public StreamResult() {}
+ public StreamResult() {
+ }
/**
* Construct a StreamResult from a byte stream. Normally,
@@ -181,19 +148,39 @@ public class StreamResult implements Result {
}
/**
- * Set the system ID from a File reference.
+ * Set the system ID from a File reference.
+ *
+ * Note the use of {@link File#toURI()} and {@link File#toURL()}.
+ * toURI() is prefered and used if possible.
+ * To allow JAXP 1.3 to run on J2SE 1.3, toURL()
+ * is used if a {@link NoSuchMethodException} is thrown by the attempt
+ * to use toURI().
*
* @param f Must a non-null File reference.
*/
public void setSystemId(File f) {
- String fpath=f.getAbsolutePath();
- if (File.separatorChar != '/') {
- fpath = fpath.replace(File.separatorChar, '/');
- }
- if( fpath.startsWith("/"))
- this.systemId= "file://" + fpath;
- else
- this.systemId = "file:///" + fpath;
+
+ try {
+ // assume >= 1.4
+ this.systemId = f.toURI().toString();
+ } catch (java.lang.NoSuchMethodError nme) {
+ // running on J2SE 1.3?
+ try {
+ this.systemId = f.toURL().toString();
+ } catch (MalformedURLException malformedURLException) {
+ this.systemId = null;
+ throw new RuntimeException(
+ "javax.xml.transform.stream.StreamResult#setSystemId(File f) with MalformedURLException: "
+ + malformedURLException.toString()
+ );
+ }
+ } catch (Exception exception) {
+ throw new RuntimeException(
+ "javax.xml.transform.stream.StreamResult#setSystemId(File f):"
+ + " unexpected Exception: " + exception.toString()
+ );
+
+ }
}
/**
diff --git a/java/external/src/javax/xml/transform/stream/StreamSource.java b/java/external/src/javax/xml/transform/stream/StreamSource.java
index e4d1ee3..bfbcfd3 100644
--- a/java/external/src/javax/xml/transform/stream/StreamSource.java
+++ b/java/external/src/javax/xml/transform/stream/StreamSource.java
@@ -1,69 +1,38 @@
/*
- * The Apache Software License, Version 1.1
+ * 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
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "Apache Software Foundation" must not be used to endorse or
- * promote products derived from this software without prior written
- * permission. For written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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.
*/
+
+// $Id$
+
package javax.xml.transform.stream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.Reader;
+
import javax.xml.transform.Source;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.File;
-
-
/**
- * Acts as an holder for a transformation Source in the form
- * of a stream of XML markup.
+ * Acts as an holder for a transformation Source in the form
+ * of a stream of XML markup.
*
+ * Note: Due to their internal use of either a {@link Reader} or {@link InputStream} instance,
+ * StreamSource instances may only be used once.
+ *
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
*/
public class StreamSource implements Source {
@@ -73,13 +42,19 @@ public class StreamSource implements Source {
*/
public static final String FEATURE =
"http://javax.xml.transform.stream.StreamSource/feature";
-
+
/**
- * Zero-argument default constructor. If this constructor
- * is used, and no other method is called, the transformer
- * will assume an empty input tree, with a default root node.
- */
- public StreamSource() {}
+ * Zero-argument default constructor. If this constructor is used, and
+ * no Stream source is set using
+ * {@link #setInputStream(java.io.InputStream inputStream)} or
+ * {@link #setReader(java.io.Reader reader)}, then the
+ * Transformer will
+ * create an empty source {@link java.io.InputStream} using
+ * {@link java.io.InputStream#InputStream() new InputStream()}.
+ *
+ * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
+ */
+ public StreamSource() { }
/**
* Construct a StreamSource from a byte stream. Normally,
@@ -268,14 +243,14 @@ public class StreamSource implements Source {
* @param f Must a non-null File reference.
*/
public void setSystemId(File f) {
- String fpath=f.getAbsolutePath();
- if (File.separatorChar != '/') {
- fpath = fpath.replace(File.separatorChar, '/');
- }
+ String fpath=f.getAbsolutePath();
+ if (File.separatorChar != '/') {
+ fpath = fpath.replace(File.separatorChar, '/');
+ }
if( fpath.startsWith("/"))
- this.systemId= "file://" + fpath;
- else
- this.systemId = "file:///" + fpath;
+ this.systemId= "file://" + fpath;
+ else
+ this.systemId = "file:///" + fpath;
}
//////////////////////////////////////////////////////////////////////
diff --git a/java/external/src/javax/xml/validation/Schema.java b/java/external/src/javax/xml/validation/Schema.java
new file mode 100644
index 0000000..df16205
--- /dev/null
+++ b/java/external/src/javax/xml/validation/Schema.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.validation;
+
+/**
+ * Immutable in-memory representation of grammar.
+ *
+ *
+ * This object represents a set of constraints that can be checked/
+ * enforced against an XML document.
+ *
+ *
+ * A {@link Schema} object is thread safe and applications are
+ * encouraged to share it across many parsers in many threads.
+ *
+ *
+ * A {@link Schema} object is immutable in the sense that it shouldn't
+ * change the set of constraints once it is created. In other words,
+ * if an application validates the same document twice against the same
+ * {@link Schema}, it must always produce the same result.
+ *
+ *
+ * A {@link Schema} object is usually created from {@link SchemaFactory}.
+ *
+ *
+ * Two kinds of validators can be created from a {@link Schema} object.
+ * One is {@link Validator}, which provides highly-level validation
+ * operations that cover typical use cases. The other is
+ * {@link ValidatorHandler}, which works on top of SAX for better
+ * modularity.
+ *
+ *
+ * This specification does not refine
+ * the {@link java.lang.Object#equals(java.lang.Object)} method.
+ * In other words, if you parse the same schema twice, you may
+ * still get !schemaA.equals(schemaB).
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @see XML Schema Part 1: Structures
+ * @see Extensible Markup Language (XML) 1.1
+ * @see Extensible Markup Language (XML) 1.0 (Second Edition)
+ * @since 1.5
+ */
+public abstract class Schema {
+
+ /**
+ * Constructor for the derived class.
+ *
+ *
+ * The constructor does nothing.
+ */
+ protected Schema() {
+ }
+
+ /**
+ * Creates a new {@link Validator} for this {@link Schema}.
+ *
+ *
+ * A validator enforces/checks the set of constraints this object
+ * represents.
+ *
+ * @return
+ * Always return a non-null valid object.
+ */
+ public abstract Validator newValidator();
+
+ /**
+ * Creates a new {@link ValidatorHandler} for this {@link Schema}.
+ *
+ * @return
+ * Always return a non-null valid object.
+ */
+ public abstract ValidatorHandler newValidatorHandler();
+}
diff --git a/java/external/src/javax/xml/validation/SchemaFactory.java b/java/external/src/javax/xml/validation/SchemaFactory.java
new file mode 100644
index 0000000..080af85
--- /dev/null
+++ b/java/external/src/javax/xml/validation/SchemaFactory.java
@@ -0,0 +1,644 @@
+/*
+ * 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.
+ */
+
+// $Id$
+
+package javax.xml.validation;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * Factory that creates {@link Schema} objects. Entry-point to
+ * the validation API.
+ *
+ *
+ * {@link SchemaFactory} is a schema compiler. It reads external
+ * representations of schemas and prepares them for validation.
+ *
+ *
+ * The {@link SchemaFactory} class is not thread-safe. In other words,
+ * it is the application's responsibility to ensure that at most
+ * one thread is using a {@link SchemaFactory} object at any
+ * given moment. Implementations are encouraged to mark methods
+ * as synchronized to protect themselves from broken clients.
+ *
+ *
+ * {@link SchemaFactory} is not re-entrant. While one of the
+ * newSchema methods is being invoked, applications
+ * may not attempt to recursively invoke the newSchema method,
+ * even from the same thread.
+ *
+ *
Schema Language
+ *
+ * This spec uses a namespace URI to designate a schema language.
+ * The following table shows the values defined by this specification.
+ *
+ * To be compliant with the spec, the implementation
+ * is only required to support W3C XML Schema 1.0. However,
+ * if it chooses to support other schema languages listed here,
+ * it must conform to the relevant behaviors described in this spec.
+ *
+ *
+ * Schema languages not listed here are expected to
+ * introduce their own URIs to represent themselves.
+ * The {@link SchemaFactory} class is capable of locating other
+ * implementations for other schema languages at run-time.
+ *
+ *
+ * Note that because the XML DTD is strongly tied to the parsing process
+ * and has a significant effect on the parsing process, it is impossible
+ * to define the DTD validation as a process independent from parsing.
+ * For this reason, this specification does not define the semantics for
+ * the XML DTD. This doesn't prohibit implentors from implementing it
+ * in a way they see fit, but users are warned that any DTD
+ * validation implemented on this interface necessarily deviate from
+ * the XML DTD semantics as defined in the XML 1.0.
+ *
+ *
+ *
+ *
+ * value
+ * language
+ *
+ *
+ *
+ *
+ * {@link javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI} ("http://www.w3.org/2001/XMLSchema")
+ * W3C XML Schema 1.0
+ *
+ *
+ * {@link javax.xml.XMLConstants#RELAXNG_NS_URI} ("http://relaxng.org/ns/structure/1.0")
+ * RELAX NG 1.0
+ *
+ *
+ *
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class SchemaFactory {
+
+ private static SecuritySupport ss = new SecuritySupport();
+
+ /**
+ * Constructor for derived classes.
+ *
+ * The constructor does nothing.
+ *
+ * Derived classes must create {@link SchemaFactory} objects that have
+ * null {@link ErrorHandler} and
+ * null {@link LSResourceResolver}.
+ */
+ protected SchemaFactory() {
+ }
+
+ /**
+ * Lookup an implementation of the SchemaFactory that supports the specified
+ * schema language and return it.
+ *
+ * To find a SchemaFactory object for a given schema language,
+ * this method looks the following places in the following order
+ * where "the class loader" refers to the context class loader:
+ *
+ * -
+ * If the system property
+ *
"javax.xml.validation.SchemaFactory:schemaLanguage"
+ * is present (where schemaLanguage is the parameter
+ * to this method), then its value is read
+ * as a class name. The method will try to
+ * create a new instance of this class by using the class loader,
+ * and returns it if it is successfully created.
+ *
+ * -
+ *
$java.home/lib/jaxp.properties is read and
+ * the value associated with the key being the system property above
+ * is looked for. If present, the value is processed just like above.
+ *
+ * -
+ *
The class loader is asked for service provider provider-configuration files matching
+ * javax.xml.validation.SchemaFactory in the resource directory META-INF/services.
+ * See the JAR File Specification for file format and parsing rules.
+ * Each potential service provider is required to implement the method:
+ *
+ * {@link #isSchemaLanguageSupported(String schemaLanguage)}
+ *
+ * The first service provider found in class loader order that supports the specified schema language is returned.
+ *
+ * -
+ * Platform default
SchemaFactory is located
+ * in a implementation specific way. There must be a platform default
+ * SchemaFactory for W3C XML Schema.
+ *
+ *
+ *
+ * If everything fails, {@link IllegalArgumentException} will be thrown.
+ *
+ * Tip for Trouble-shooting:
+ * See {@link java.util.Properties#load(java.io.InputStream)} for
+ * exactly how a property file is parsed. In particular, colons ':'
+ * need to be escaped in a property file, so make sure schema language
+ * URIs are properly escaped in it. For example:
+ *
+ * http\://www.w3.org/2001/XMLSchema=org.acme.foo.XSSchemaFactory
+ *
+ *
+ * @param schemaLanguage
+ * Specifies the schema language which the returned
+ * SchemaFactory will understand. See
+ * the list of available
+ * schema languages for the possible values.
+ *
+ * @return New instance of a SchemaFactory
+ *
+ * @throws IllegalArgumentException
+ * If no implementation of the schema language is available.
+ *
+ * @throws NullPointerException
+ * If the schemLanguage parameter is null.
+ */
+ public static final SchemaFactory newInstance(String schemaLanguage) {
+ ClassLoader cl;
+ cl = ss.getContextClassLoader();
+
+ if (cl == null) {
+ //cl = ClassLoader.getSystemClassLoader();
+ //use the current class loader
+ cl = SchemaFactory.class.getClassLoader();
+ }
+
+ SchemaFactory f = new SchemaFactoryFinder(cl).newFactory(schemaLanguage);
+ if (f == null) {
+ throw new IllegalArgumentException(schemaLanguage);
+ }
+ return f;
+ }
+
+ /**
+ * Is specified schema supported by this SchemaFactory?
+ *
+ * @param schemaLanguage Specifies the schema language which the returned SchemaFactory will understand.
+ * schemaLanguage must specify a valid schema language.
+ *
+ * @return true if SchemaFactory supports schemaLanguage, else false.
+ *
+ * @throws NullPointerException If schemaLanguage is null.
+ * @throws IllegalArgumentException If schemaLanguage.length() == 0
+ * or schemaLanguage does not specify a valid schema language.
+ */
+ public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
+
+ /**
+ * Look up the value of a feature flag.
+ *
+ * The feature name is any fully-qualified URI. It is
+ * possible for a {@link SchemaFactory} to recognize a feature name but
+ * temporarily be unable to return its value.
+ *
+ *
Implementors are free (and encouraged) to invent their own features,
+ * using names built on their own URIs.
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @return The current value of the feature (true or false).
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link SchemaFactory} recognizes the feature name but
+ * cannot determine its value at this time.
+ * @exception NullPointerException
+ * if the name parameter is null.
+ * @see #setFeature(String, boolean)
+ */
+ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (name == null) {
+ throw new NullPointerException("the name parameter is null");
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a feature flag.
+ *
+ *
+ * Feature can be used to control the way a {@link SchemaFactory}
+ * parses schemas, although {@link SchemaFactory}s are not required
+ * to recognize any specific feature names.
+ *
+ * The feature name is any fully-qualified URI. It is
+ * possible for a {@link SchemaFactory} to expose a feature value but
+ * to be unable to change the current value.
+ *
+ * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
+ * When the feature is:
+ *
+ * -
+ *
true: the implementation will limit XML processing to conform to implementation limits.
+ * Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+ * If XML processing is limited for security reasons, it will be reported via a call to the registered
+ * {@link ErrorHandler#fatalError(SAXParseException exception)}.
+ * See {@link #setErrorHandler(ErrorHandler errorHandler)}.
+ *
+ * -
+ *
false: the implementation will processing XML according to the XML specifications without
+ * regard to possible implementation limits.
+ *
+ *
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @param value The requested value of the feature (true or false).
+ *
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link SchemaFactory} recognizes the feature name but
+ * cannot set the requested value.
+ * @exception NullPointerException
+ * if the name parameter is null.
+ *
+ * @see #getFeature(String)
+ */
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (name == null) {
+ throw new NullPointerException("the name parameter is null");
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link SchemaFactory} to recognize a property name but
+ * to be unable to change the current value.
+ *
+ * {@link SchemaFactory}s are not required to recognize setting
+ * any specific property names.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @param object The requested value for the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link SchemaFactory} recognizes the property name but
+ * cannot set the requested value.
+ * @exception NullPointerException
+ * if the name parameter is null.
+ */
+ public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (name == null) {
+ throw new NullPointerException("the name parameter is null");
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Look up the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link SchemaFactory} to recognize a property name but
+ * temporarily be unable to return its value.
+ *
+ * {@link SchemaFactory}s are not required to recognize any specific
+ * property names.
+ *
+ * Implementors are free (and encouraged) to invent their own properties,
+ * using names built on their own URIs.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @return The current value of the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the property name but
+ * cannot determine its value at this time.
+ * @exception NullPointerException
+ * if the name parameter is null.
+ * @see #setProperty(String, Object)
+ */
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (name == null) {
+ throw new NullPointerException("the name parameter is null");
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Sets the {@link ErrorHandler} to receive errors encountered
+ * during the newSchema method invocation.
+ *
+ *
+ * Error handler can be used to customize the error handling process
+ * during schema parsing. When an {@link ErrorHandler} is set,
+ * errors found during the parsing of schemas will be first sent
+ * to the {@link ErrorHandler}.
+ *
+ *
+ * The error handler can abort the parsing of a schema immediately
+ * by throwing {@link SAXException} from the handler. Or for example
+ * it can print an error to the screen and try to continue the
+ * processing by returning normally from the {@link ErrorHandler}
+ *
+ *
+ * If any {@link Throwable} (or instances of its derived classes)
+ * is thrown from an {@link ErrorHandler},
+ * the caller of the newSchema method will be thrown
+ * the same {@link Throwable} object.
+ *
+ *
+ * {@link SchemaFactory} is not allowed to
+ * throw {@link SAXException} without first reporting it to
+ * {@link ErrorHandler}.
+ *
+ *
+ * Applications can call this method even during a {@link Schema}
+ * is being parsed.
+ *
+ *
+ * When the {@link ErrorHandler} is null, the implementation will
+ * behave as if the following {@link ErrorHandler} is set:
+ *
+ * class DraconianErrorHandler implements {@link ErrorHandler} {
+ * public void fatalError( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * throw e;
+ * }
+ * public void error( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * throw e;
+ * }
+ * public void warning( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * // noop
+ * }
+ * }
+ *
+ *
+ *
+ * When a new {@link SchemaFactory} object is created, initially
+ * this field is set to null. This field will NOT be
+ * inherited to {@link Schema}s, {@link Validator}s, or
+ * {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.
+ *
+ *
+ * @param errorHandler
+ * A new error handler to be set. This parameter can be null.
+ */
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ /**
+ * Gets the current {@link ErrorHandler} set to this {@link SchemaFactory}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setErrorHandler(ErrorHandler)} method, or null
+ * if that method has never been called since this {@link SchemaFactory}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract ErrorHandler getErrorHandler();
+
+ /**
+ * Sets the {@link LSResourceResolver} to customize
+ * resource resolution when parsing schemas.
+ *
+ *
+ * {@link SchemaFactory} uses a {@link LSResourceResolver}
+ * when it needs to locate external resources while parsing schemas,
+ * although exactly what constitutes "locating external resources" is
+ * up to each schema language. For example, for W3C XML Schema,
+ * this includes files <include>d or <import>ed,
+ * and DTD referenced from schema files, etc.
+ *
+ *
+ * Applications can call this method even during a {@link Schema}
+ * is being parsed.
+ *
+ *
+ * When the {@link LSResourceResolver} is null, the implementation will
+ * behave as if the following {@link LSResourceResolver} is set:
+ *
+ * class DumbDOMResourceResolver implements {@link LSResourceResolver} {
+ * public {@link org.w3c.dom.ls.LSInput} resolveResource(
+ * String publicId, String systemId, String baseURI) {
+ *
+ * return null; // always return null
+ * }
+ * }
+ *
+ *
+ *
+ * If a {@link LSResourceResolver} throws a {@link RuntimeException}
+ * (or instances of its derived classes),
+ * then the {@link SchemaFactory} will abort the parsing and
+ * the caller of the newSchema method will receive
+ * the same {@link RuntimeException}.
+ *
+ *
+ * When a new {@link SchemaFactory} object is created, initially
+ * this field is set to null. This field will NOT be
+ * inherited to {@link Schema}s, {@link Validator}s, or
+ * {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.
+ *
+ * @param resourceResolver
+ * A new resource resolver to be set. This parameter can be null.
+ */
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ /**
+ * Gets the current {@link LSResourceResolver} set to this {@link SchemaFactory}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setResourceResolver(LSResourceResolver)} method, or null
+ * if that method has never been called since this {@link SchemaFactory}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract LSResourceResolver getResourceResolver();
+
+ /**
+ *
Parses the specified source as a schema and returns it as a schema.
+ *
+ * This is a convenience method for {@link #newSchema(Source[] schemas)}.
+ *
+ * @param schema Source that represents a schema.
+ *
+ * @return New Schema from parsing schema.
+ *
+ * @throws SAXException If a SAX error occurs during parsing.
+ * @throws NullPointerException if schema is null.
+ */
+ public Schema newSchema(Source schema) throws SAXException {
+ return newSchema(new Source[]{schema});
+ }
+
+ /**
+ * Parses the specified File as a schema and returns it as a Schema.
+ *
+ * This is a convenience method for {@link #newSchema(Source schema)}.
+ *
+ * @param schema File that represents a schema.
+ *
+ * @return New Schema from parsing schema.
+ *
+ * @throws SAXException If a SAX error occurs during parsing.
+ * @throws NullPointerException if schema is null.
+ */
+ public Schema newSchema(File schema) throws SAXException {
+ return newSchema(new StreamSource(schema));
+ }
+
+ /**
+ * Parses the specified URL as a schema and returns it as a Schema.
+ *
+ * This is a convenience method for {@link #newSchema(Source schema)}.
+ *
+ * @param schema URL that represents a schema.
+ *
+ * @return New Schema from parsing schema.
+ *
+ * @throws SAXException If a SAX error occurs during parsing.
+ * @throws NullPointerException if schema is null.
+ */
+ public Schema newSchema(URL schema) throws SAXException {
+ return newSchema(new StreamSource(schema.toExternalForm()));
+ }
+
+ /**
+ * Parses the specified source(s) as a schema and returns it as a schema.
+ *
+ *
+ * The callee will read all the {@link Source}s and combine them into a
+ * single schema. The exact semantics of the combination depends on the schema
+ * language that this {@link SchemaFactory} object is created for.
+ *
+ *
+ * When an {@link ErrorHandler} is set, the callee will report all the errors
+ * found in sources to the handler. If the handler throws an exception, it will
+ * abort the schema compilation and the same exception will be thrown from
+ * this method. Also, after an error is reported to a handler, the callee is allowed
+ * to abort the further processing by throwing it. If an error handler is not set,
+ * the callee will throw the first error it finds in the sources.
+ *
+ *
W3C XML Schema 1.0
+ *
+ * The resulting schema contains components from the specified sources.
+ * The same result would be achieved if all these sources were
+ * imported, using appropriate values for schemaLocation and namespace,
+ * into a single schema document with a different targetNamespace
+ * and no components of its own, if the import elements were given
+ * in the same order as the sources. Section 4.2.3 of the XML Schema
+ * recommendation describes the options processors have in this
+ * regard. While a processor should be consistent in its treatment of
+ * JAXP schema sources and XML Schema imports, the behaviour between
+ * JAXP-compliant parsers may vary; in particular, parsers may choose
+ * to ignore all but the first <import> for a given namespace,
+ * regardless of information provided in schemaLocation.
+ *
+ *
+ * If the parsed set of schemas includes error(s) as
+ * specified in the section 5.1 of the XML Schema spec, then
+ * the error must be reported to the {@link ErrorHandler}.
+ *
+ *
RELAX NG
+ *
+ * For RELAX NG, this method must throw {@link UnsupportedOperationException}
+ * if schemas.length!=1.
+ *
+ *
+ * @param schemas
+ * inputs to be parsed. {@link SchemaFactory} is required
+ * to recognize {@link javax.xml.transform.sax.SAXSource},
+ * {@link StreamSource}, and {@link javax.xml.transform.dom.DOMSource}.
+ *
+ * @return
+ * Always return a non-null valid {@link Schema} object.
+ * Note that when an error has been reported, there is no
+ * guarantee that the returned {@link Schema} object is
+ * meaningful.
+ *
+ * @throws SAXException
+ * If an error is found during processing the specified inputs.
+ * When an {@link ErrorHandler} is set, errors are reported to
+ * there first. See {@link #setErrorHandler(ErrorHandler)}.
+ * @throws NullPointerException
+ * If the schemas parameter itself is null or
+ * any item in the array is null.
+ * @throws IllegalArgumentException
+ * If any item in the array is not recognized by this method.
+ * @throws UnsupportedOperationException
+ * If the schema language doesn't support this operation.
+ */
+ public abstract Schema newSchema(Source[] schemas) throws SAXException;
+
+ /**
+ * Creates a special {@link Schema} object.
+ *
+ *
+ * The exact semantics of the returned {@link Schema} object depends
+ * on the schema language that this {@link SchemaFactory} is created
+ * for.
+ *
+ *
+ * Also, implementations are allowed to use implementation-specific
+ * property/feature to alter the semantics of this method.
+ *
+ *
+ *
W3C XML Schema 1.0
+ *
+ * For XML Schema, this method creates a {@link Schema} object that
+ * performs validation by using location hints specified in documents.
+ *
+ *
+ * The returned {@link Schema} object assumes that if documents
+ * refer to the same URL in the schema location hints,
+ * they will always resolve to the same schema document. This
+ * asusmption allows implementations to reuse parsed results of
+ * schema documents so that multiple validations against the same
+ * schema will run faster.
+ *
+ *
+ * Note that the use of schema location hints introduces a
+ * vulnerability to denial-of-service attacks.
+ *
+ *
+ *
RELAX NG
+ *
+ * RELAX NG does not support this operation.
+ *
+ * @return
+ * Always return non-null valid {@link Schema} object.
+ *
+ * @throws UnsupportedOperationException
+ * If this operation is not supported by the callee.
+ * @throws SAXException
+ * If this operation is supported but failed for some reason.
+ */
+ public abstract Schema newSchema() throws SAXException;
+}
diff --git a/java/external/src/javax/xml/validation/SchemaFactoryFinder.java b/java/external/src/javax/xml/validation/SchemaFactoryFinder.java
new file mode 100644
index 0000000..760697b
--- /dev/null
+++ b/java/external/src/javax/xml/validation/SchemaFactoryFinder.java
@@ -0,0 +1,397 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.validation;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+
+/**
+ * Implementation of {@link SchemaFactory#newInstance(String)}.
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+class SchemaFactoryFinder {
+
+ /** debug support code. */
+ private static boolean debug = false;
+ /**
+ *
Take care of restrictions imposed by java security model
+ */
+ private static SecuritySupport ss = new SecuritySupport();
+ /**
+ * Cache properties for performance.
+ */
+ private static Properties cacheProps = new Properties();
+
+ /**
+ * First time requires initialization overhead.
+ */
+ private static boolean firstTime = true;
+
+ static {
+ // Use try/catch block to support applets
+ try {
+ debug = ss.getSystemProperty("jaxp.debug") != null;
+ } catch (Exception _) {
+ debug = false;
+ }
+ }
+
+ /**
+ * Conditional debug printing.
+ *
+ * @param msg to print
+ */
+ private static void debugPrintln(String msg) {
+ if (debug) {
+ System.err.println("JAXP: " + msg);
+ }
+ }
+
+ /**
+ * ClassLoader to use to find SchemaFactory.
+ */
+ private final ClassLoader classLoader;
+
+ /**
+ * Constructor that specifies ClassLoader to use
+ * to find SchemaFactory.
+ *
+ * @param loader
+ * to be used to load resource, {@link SchemaFactory}, and
+ * {@link SchemaFactoryLoader} implementations during
+ * the resolution process.
+ * If this parameter is null, the default system class loader
+ * will be used.
+ */
+ public SchemaFactoryFinder(ClassLoader loader) {
+ this.classLoader = loader;
+ if( debug ) {
+ debugDisplayClassLoader();
+ }
+ }
+
+ private void debugDisplayClassLoader() {
+ try {
+ if( classLoader == ss.getContextClassLoader() ) {
+ debugPrintln("using thread context class loader ("+classLoader+") for search");
+ return;
+ }
+ } catch( Throwable _ ) {
+ ; // getContextClassLoader() undefined in JDK1.1
+ }
+
+ if( classLoader==ClassLoader.getSystemClassLoader() ) {
+ debugPrintln("using system class loader ("+classLoader+") for search");
+ return;
+ }
+
+ debugPrintln("using class loader ("+classLoader+") for search");
+ }
+
+ /**
+ * Creates a new {@link SchemaFactory} object for the specified
+ * schema language.
+ *
+ * @param schemaLanguage
+ * See {@link SchemaFactory Schema Language} table in SchemaFactory
+ * for the list of available schema languages.
+ *
+ * @return null if the callee fails to create one.
+ *
+ * @throws NullPointerException
+ * If the schemaLanguage parameter is null.
+ */
+ public SchemaFactory newFactory(String schemaLanguage) {
+ if(schemaLanguage==null) throw new NullPointerException();
+ SchemaFactory f = _newFactory(schemaLanguage);
+ if (f != null) {
+ debugPrintln("factory '" + f.getClass().getName() + "' was found for " + schemaLanguage);
+ } else {
+ debugPrintln("unable to find a factory for " + schemaLanguage);
+ }
+ return f;
+ }
+
+ /**
+ * Lookup a SchemaFactory for the given schemaLanguage.
+ *
+ * @param schemaLanguage Schema language to lookup SchemaFactory for.
+ *
+ * @return SchemaFactory for the given schemaLanguage.
+ */
+ private SchemaFactory _newFactory(String schemaLanguage) {
+ SchemaFactory sf;
+
+ String propertyName = SERVICE_CLASS.getName() + ":" + schemaLanguage;
+
+ // system property look up
+ try {
+ debugPrintln("Looking up system property '"+propertyName+"'" );
+ String r = ss.getSystemProperty(propertyName);
+ if(r!=null) {
+ debugPrintln("The value is '"+r+"'");
+ sf = createInstance(r);
+ if(sf!=null) return sf;
+ } else
+ debugPrintln("The property is undefined.");
+ } catch( Throwable t ) {
+ if( debug ) {
+ debugPrintln("failed to look up system property '"+propertyName+"'" );
+ t.printStackTrace();
+ }
+ }
+
+ String javah = ss.getSystemProperty( "java.home" );
+ String configFile = javah + File.separator +
+ "lib" + File.separator + "jaxp.properties";
+
+ String factoryClassName = null ;
+
+ // try to read from $java.home/lib/jaxp.properties
+ try {
+ if(firstTime){
+ synchronized(cacheProps){
+ if(firstTime){
+ File f=new File( configFile );
+ firstTime = false;
+ if(ss.doesFileExist(f)){
+ debugPrintln("Read properties file " + f);
+ cacheProps.load(ss.getFileInputStream(f));
+ }
+ }
+ }
+ }
+ factoryClassName = cacheProps.getProperty(propertyName);
+ debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
+
+ if (factoryClassName != null) {
+ sf = createInstance(factoryClassName);
+ if(sf != null){
+ return sf;
+ }
+ }
+ } catch (Exception ex) {
+ if (debug) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ // try to read from $java.home/lib/jaxp.properties
+ try {
+ String javah = ss.getSystemProperty( "java.home" );
+ String configFile = javah + File.separator +
+ "lib" + File.separator + "jaxp.properties";
+ File f = new File( configFile );
+ if( ss.doesFileExist(f)) {
+ sf = loadFromProperty(
+ propertyName,f.getAbsolutePath(), new FileInputStream(f));
+ if(sf!=null) return sf;
+ } else {
+ debugPrintln("Tried to read "+ f.getAbsolutePath()+", but it doesn't exist.");
+ }
+ } catch(Throwable e) {
+ if( debug ) {
+ debugPrintln("failed to read $java.home/lib/jaxp.properties");
+ e.printStackTrace();
+ }
+ }
+ */
+
+ // try META-INF/services files
+ Iterator sitr = createServiceFileIterator();
+ while(sitr.hasNext()) {
+ URL resource = (URL)sitr.next();
+ debugPrintln("looking into " + resource);
+ try {
+ //sf = loadFromProperty(schemaLanguage,resource.toExternalForm(),resource.openStream());
+ sf = loadFromProperty(schemaLanguage,resource.toExternalForm(),ss.getURLInputStream(resource));
+ if(sf!=null) return sf;
+ } catch(IOException e) {
+ if( debug ) {
+ debugPrintln("failed to read "+resource);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ // platform default
+ if(schemaLanguage.equals("http://www.w3.org/2001/XMLSchema")) {
+ debugPrintln("attempting to use the platform default XML Schema validator");
+ return createInstance("org.apache.xerces.jaxp.validation.xs.SchemaFactoryImpl");
+ }
+
+ debugPrintln("all things were tried, but none was found. bailing out.");
+ return null;
+ }
+
+ /**
+ * Creates an instance of the specified and returns it.
+ *
+ * @param className
+ * fully qualified class name to be instanciated.
+ *
+ * @return null
+ * if it fails. Error messages will be printed by this method.
+ */
+ private SchemaFactory createInstance( String className ) {
+ try {
+ debugPrintln("instanciating "+className);
+ Class clazz;
+ if( classLoader!=null )
+ clazz = classLoader.loadClass(className);
+ else
+ clazz = Class.forName(className);
+ if(debug) debugPrintln("loaded it from "+which(clazz));
+ Object o = clazz.newInstance();
+
+ if( o instanceof SchemaFactory )
+ return (SchemaFactory)o;
+
+ debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
+ } catch( Throwable t ) {
+ debugPrintln("failed to instanciate "+className);
+ if(debug) t.printStackTrace();
+ }
+ return null;
+ }
+
+ /** Iterator that lazily computes one value and returns it. */
+ private static abstract class SingleIterator implements Iterator {
+ private boolean seen = false;
+
+ public final void remove() { throw new UnsupportedOperationException(); }
+ public final boolean hasNext() { return !seen; }
+ public final Object next() {
+ if(seen) throw new NoSuchElementException();
+ seen = true;
+ return value();
+ }
+
+ protected abstract Object value();
+ }
+
+ /**
+ * Looks up a value in a property file
+ * while producing all sorts of debug messages.
+ *
+ * @return null
+ * if there was an error.
+ */
+ private SchemaFactory loadFromProperty( String keyName, String resourceName, InputStream in )
+ throws IOException {
+ debugPrintln("Reading "+resourceName );
+
+ Properties props=new Properties();
+ props.load(in);
+ in.close();
+ String factoryClassName = props.getProperty(keyName);
+ if(factoryClassName != null){
+ debugPrintln("found "+keyName+" = " + factoryClassName);
+ return createInstance(factoryClassName);
+ } else {
+ debugPrintln(keyName+" is not in the property file");
+ return null;
+ }
+ }
+
+ /**
+ * Returns an {@link Iterator} that enumerates all
+ * the META-INF/services files that we care.
+ */
+ private Iterator createServiceFileIterator() {
+ if (classLoader == null) {
+ return new SingleIterator() {
+ protected Object value() {
+ ClassLoader classLoader = SchemaFactoryFinder.class.getClassLoader();
+ //return (ClassLoader.getSystemResource( SERVICE_ID ));
+ return ss.getResourceAsURL(classLoader, SERVICE_ID);
+ }
+ };
+ } else {
+ try {
+ //final Enumeration e = classLoader.getResources(SERVICE_ID);
+ final Enumeration e = ss.getResources(classLoader, SERVICE_ID);
+ if(!e.hasMoreElements()) {
+ debugPrintln("no "+SERVICE_ID+" file was found");
+ }
+
+ // wrap it into an Iterator.
+ return new Iterator() {
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext() {
+ return e.hasMoreElements();
+ }
+
+ public Object next() {
+ return e.nextElement();
+ }
+ };
+ } catch (IOException e) {
+ debugPrintln("failed to enumerate resources "+SERVICE_ID);
+ if(debug) e.printStackTrace();
+ return new ArrayList().iterator(); // empty iterator
+ }
+ }
+ }
+
+ private static final Class SERVICE_CLASS = SchemaFactory.class;
+ private static final String SERVICE_ID = "META-INF/services/" + SERVICE_CLASS.getName();
+
+
+
+ private static String which( Class clazz ) {
+ return which( clazz.getName(), clazz.getClassLoader() );
+ }
+
+ /**
+ * Search the specified classloader for the given classname.
+ *
+ * @param classname the fully qualified name of the class to search for
+ * @param loader the classloader to search
+ *
+ * @return the source location of the resource, or null if it wasn't found
+ */
+ private static String which(String classname, ClassLoader loader) {
+
+ String classnameAsResource = classname.replace('.', '/') + ".class";
+
+ if( loader==null ) loader = ClassLoader.getSystemClassLoader();
+
+ //URL it = loader.getResource(classnameAsResource);
+ URL it = ss.getResourceAsURL(loader, classnameAsResource);
+ if (it != null) {
+ return it.toString();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/java/external/src/javax/xml/validation/SecuritySupport.java b/java/external/src/javax/xml/validation/SecuritySupport.java
new file mode 100644
index 0000000..72e0dc6
--- /dev/null
+++ b/java/external/src/javax/xml/validation/SecuritySupport.java
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.validation;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * This class is duplicated for each JAXP subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXP
+ * API.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+class SecuritySupport {
+
+
+ ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) { }
+ return cl;
+ }
+ });
+ }
+
+ String getSystemProperty(final String propName) {
+ return (String)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(propName);
+ }
+ });
+ }
+
+ FileInputStream getFileInputStream(final File file)
+ throws FileNotFoundException
+ {
+ try {
+ return (FileInputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(file);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException)e.getException();
+ }
+ }
+
+ InputStream getURLInputStream(final URL url)
+ throws IOException
+ {
+ try {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return url.openStream();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException)e.getException();
+ }
+ }
+
+ URL getResourceAsURL(final ClassLoader cl,
+ final String name)
+ {
+ return (URL)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ URL url;
+ if (cl == null) {
+ url = ClassLoader.getSystemResource(name);
+ } else {
+ url = cl.getSystemResource(name);
+ }
+ return url;
+ }
+ });
+ }
+
+ Enumeration getResources(final ClassLoader cl,
+ final String name) throws IOException
+ {
+ try{
+ return (Enumeration)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException{
+ Enumeration enumeration;
+ if (cl == null) {
+ enumeration = ClassLoader.getSystemResources(name);
+ } else {
+ enumeration = cl.getSystemResources(name);
+ }
+ return enumeration;
+ }
+ });
+ }catch(PrivilegedActionException e){
+ throw (IOException)e.getException();
+ }
+ }
+
+ InputStream getResourceAsStream(final ClassLoader cl,
+ final String name)
+ {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ InputStream ris;
+ if (cl == null) {
+ ris = ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = cl.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
+ }
+
+ boolean doesFileExist(final File f) {
+ return ((Boolean)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(f.exists());
+ }
+ })).booleanValue();
+ }
+
+}
diff --git a/java/external/src/javax/xml/validation/TypeInfoProvider.java b/java/external/src/javax/xml/validation/TypeInfoProvider.java
new file mode 100644
index 0000000..0eb869f
--- /dev/null
+++ b/java/external/src/javax/xml/validation/TypeInfoProvider.java
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.validation;
+
+import org.w3c.dom.TypeInfo;
+
+/**
+ * This class provides access to the type information determined
+ * by {@link ValidatorHandler}.
+ *
+ *
+ * Some schema languages, such as W3C XML Schema, encourages a validator
+ * to report the "type" it assigns to each attribute/element.
+ * Those applications who wish to access this type information can invoke
+ * methods defined on this "interface" to access such type information.
+ *
+ *
+ * Implementation of this "interface" can be obtained through the
+ * {@link ValidatorHandler#getTypeInfoProvider()} method.
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @see org.w3c.dom.TypeInfo
+ * @since 1.5
+ */
+public abstract class TypeInfoProvider {
+
+ /**
+ * Constructor for the derived class.
+ *
+ *
+ * The constructor does nothing.
+ */
+ protected TypeInfoProvider() {
+ }
+
+ /**
+ *
Returns the immutable {@link TypeInfo} object for the current element.
+ *
+ *
+ * The method may only be called by the startElement event of
+ * the {@link org.xml.sax.ContentHandler} that the application sets to the
+ * {@link ValidatorHandler}.
+ *
+ * @throws IllegalStateException
+ * If this method is called from other {@link org.xml.sax.ContentHandler}
+ * methods.
+ * @return
+ * An immutable {@link TypeInfo} object that represents the
+ * type of the current element.
+ * Note that the caller can keep references to the obtained
+ * {@link TypeInfo} longer than the callback scope.
+ *
+ * Otherwise, this method returns
+ * null if the validator is unable to
+ * determine the type of the current element for some reason
+ * (for example, if the validator is recovering from
+ * an earlier error.)
+ *
+ */
+ public abstract TypeInfo getElementTypeInfo();
+
+ /**
+ * Returns the immutable {@link TypeInfo} object for the specified
+ * attribute of the current element.
+ *
+ *
+ * The method may only be called by the startElement event of
+ * the {@link org.xml.sax.ContentHandler} that the application sets to the
+ * {@link ValidatorHandler}.
+ *
+ * @param index
+ * The index of the attribute. The same index for
+ * the {@link org.xml.sax.Attributes} object passed to the
+ * startElement callback.
+ *
+ * @throws IndexOutOfBoundsException
+ * If the index is invalid.
+ * @throws IllegalStateException
+ * If this method is called from other {@link org.xml.sax.ContentHandler}
+ * methods.
+ *
+ * @return
+ * An immutable {@link TypeInfo} object that represents the
+ * type of the specified attribute.
+ * Note that the caller can keep references to the obtained
+ * {@link TypeInfo} longer than the callback scope.
+ *
+ * Otherwise, this method returns
+ * null if the validator is unable to
+ * determine the type.
+ */
+ public abstract TypeInfo getAttributeTypeInfo(int index);
+
+ /**
+ * Returns true if the specified attribute is determined
+ * to be ID.
+ *
+ *
+ * Exacly how an attribute is "determined to be ID" is up to the
+ * schema language. In case of W3C XML Schema, this means
+ * that the actual type of the attribute is the built-in ID type
+ * or its derived type.
+ *
+ *
+ * A {@link javax.xml.parsers.DocumentBuilder} uses this information
+ * to properly implement {@link org.w3c.dom.Attr#isId()}.
+ *
+ *
+ * The method may only be called by the startElement event of
+ * the {@link org.xml.sax.ContentHandler} that the application sets to the
+ * {@link ValidatorHandler}.
+ *
+ * @param index
+ * The index of the attribute. The same index for
+ * the {@link org.xml.sax.Attributes} object passed to the
+ * startElement callback.
+ *
+ * @throws IndexOutOfBoundsException
+ * If the index is invalid.
+ * @throws IllegalStateException
+ * If this method is called from other {@link org.xml.sax.ContentHandler}
+ * methods.
+ *
+ * @return true
+ * if the type of the specified attribute is ID.
+ */
+ public abstract boolean isIdAttribute(int index);
+
+ /**
+ * Returns false if the attribute was added by the validator.
+ *
+ *
+ * This method provides information necessary for
+ * a {@link javax.xml.parsers.DocumentBuilder} to determine what
+ * the DOM tree should return from the {@link org.w3c.dom.Attr#getSpecified()} method.
+ *
+ *
+ * The method may only be called by the startElement event of
+ * the {@link org.xml.sax.ContentHandler} that the application sets to the
+ * {@link ValidatorHandler}.
+ *
+ *
+ * A general guideline for validators is to return true if
+ * the attribute was originally present in the pipeline, and
+ * false if it was added by the validator.
+ *
+ * @param index
+ * The index of the attribute. The same index for
+ * the {@link org.xml.sax.Attributes} object passed to the
+ * startElement callback.
+ *
+ * @throws IndexOutOfBoundsException
+ * If the index is invalid.
+ * @throws IllegalStateException
+ * If this method is called from other {@link org.xml.sax.ContentHandler}
+ * methods.
+ *
+ * @return
+ * true if the attribute was present before the validator
+ * processes input. false if the attribute was added
+ * by the validator.
+ */
+ public abstract boolean isSpecified(int index);
+}
diff --git a/java/external/src/javax/xml/validation/Validator.java b/java/external/src/javax/xml/validation/Validator.java
new file mode 100644
index 0000000..3c3d036
--- /dev/null
+++ b/java/external/src/javax/xml/validation/Validator.java
@@ -0,0 +1,424 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.validation;
+
+import java.io.IOException;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ *
A processor that checks an XML document against {@link Schema}.
+ *
+ *
+ * A validator is a thread-unsafe and non-reentrant object.
+ * In other words, it is the application's responsibility to make
+ * sure that one {@link Validator} object is not used from
+ * more than one thread at any given time, and while the validate
+ * method is invoked, applications may not recursively call
+ * the validate method.
+ *
+ *
+ * Note that while the {@link #validate(javax.xml.transform.Source)} and {@link #validate(javax.xml.transform.Source, javax.xml.transform.Result)}
+ * methods take a {@link Source} instance, the Source
+ * instance must be a SAXSource or DOMSource.
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class Validator {
+
+ /**
+ * Constructor for derived classes.
+ *
+ *
+ * The constructor does nothing.
+ *
+ *
+ * Derived classes must create {@link Validator} objects that have
+ * null {@link ErrorHandler} and
+ * null {@link LSResourceResolver}.
+ */
+ protected Validator() {
+ }
+
+ /**
+ *
Reset this Validator to its original configuration.
+ *
+ * Validator is reset to the same state as when it was created with
+ * {@link Schema#newValidator()}.
+ * reset() is designed to allow the reuse of existing Validators
+ * thus saving resources associated with the creation of new Validators.
+ *
+ * The reset Validator is not guaranteed to have the same {@link LSResourceResolver} or {@link ErrorHandler}
+ * Objects, e.g. {@link Object#equals(Object obj)}. It is guaranteed to have a functionally equal
+ * LSResourceResolver and ErrorHandler.
+ */
+ public abstract void reset();
+
+ /**
+ * Validates the specified input.
+ *
+ *
+ * This is just a convenience method of:
+ *
+ * validate(source,null);
+ *
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public void validate(Source source) throws SAXException, IOException {
+ validate(source, null);
+ }
+
+ /**
+ * Validates the specified input and send the augmented validation
+ * result to the specified output.
+ *
+ *
+ * This method places the following restrictions on the types of
+ * the {@link Source}/{@link Result} accepted.
+ *
+ *
{@link Source}/{@link Result} accepted:
+ *
+ *
+ *
+ *
+ * {@link javax.xml.transform.sax.SAXSource}
+ * {@link javax.xml.transform.dom.DOMSource}
+ *
+ *
+ *
+ *
+ * null
+ * OK
+ * OK
+ *
+ *
+ * {@link javax.xml.transform.sax.SAXResult}
+ * OK
+ * Err
+ *
+ *
+ * {@link javax.xml.transform.dom.DOMResult}
+ * Err
+ * OK
+ *
+ *
+ *
+ *
+ *
+ * Note that {@link javax.xml.transform.stream.StreamSource} instances are not allowed. To process
+ * a StreamSource, or to validate one {@link Source} into another kind of {@link Result}, use the identity transformer
+ * (see {@link javax.xml.transform.TransformerFactory#newTransformer()}).
+ *
+ *
+ * Errors found during the validation is sent to the specified
+ * {@link ErrorHandler}.
+ *
+ *
+ * If a document is valid, or if a document contains some errors
+ * but none of them were fatal and the {@link ErrorHandler} didn't
+ * throw any exception, then the method returns normally.
+ *
+ * @param source
+ * XML to be validated. Must not be null.
+ *
+ * @param result
+ * The {@link Result} object that receives (possibly augmented)
+ * XML. This parameter can be null if the caller is not interested
+ * in it.
+ *
+ * Note that when a {@link javax.xml.transform.dom.DOMResult} is used,
+ * a validator might just pass the same DOM node from
+ * {@link javax.xml.transform.dom.DOMSource} to
+ * {@link javax.xml.transform.dom.DOMResult}
+ * (in which case source.getNode()==result.getNode()),
+ * it might copy the entire DOM tree, or it might alter the
+ * node given by the source.
+ *
+ * @throws IllegalArgumentException
+ * If the {@link Result} type doesn't match the {@link Source} type,
+ * or if the specified source is neither
+ * {@link javax.xml.transform.sax.SAXSource} nor
+ * {@link javax.xml.transform.dom.DOMSource}.
+ *
+ * @throws SAXException
+ * If the {@link ErrorHandler} throws a {@link SAXException} or
+ * if a fatal error is found and the {@link ErrorHandler} returns
+ * normally.
+ *
+ * @throws IOException
+ * If the validator is processing a
+ * {@link javax.xml.transform.sax.SAXSource} and the
+ * underlying {@link org.xml.sax.XMLReader} throws an
+ * {@link IOException}.
+ *
+ * @throws NullPointerException
+ * If the source parameter is null.
+ *
+ * @see #validate(Source)
+ */
+ public abstract void validate(Source source, Result result) throws SAXException, IOException;
+
+ /**
+ * Sets the {@link ErrorHandler} to receive errors encountered
+ * during the validate method invocation.
+ *
+ *
+ * Error handler can be used to customize the error handling process
+ * during a validation. When an {@link ErrorHandler} is set,
+ * errors found during the validation will be first sent
+ * to the {@link ErrorHandler}.
+ *
+ *
+ * The error handler can abort further validation immediately
+ * by throwing {@link SAXException} from the handler. Or for example
+ * it can print an error to the screen and try to continue the
+ * validation by returning normally from the {@link ErrorHandler}
+ *
+ *
+ * If any {@link Throwable} is thrown from an {@link ErrorHandler},
+ * the caller of the validate method will be thrown
+ * the same {@link Throwable} object.
+ *
+ *
+ * {@link Validator} is not allowed to
+ * throw {@link SAXException} without first reporting it to
+ * {@link ErrorHandler}.
+ *
+ *
+ * When the {@link ErrorHandler} is null, the implementation will
+ * behave as if the following {@link ErrorHandler} is set:
+ *
+ * class DraconianErrorHandler implements {@link ErrorHandler} {
+ * public void fatalError( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * throw e;
+ * }
+ * public void error( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * throw e;
+ * }
+ * public void warning( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
+ * // noop
+ * }
+ * }
+ *
+ *
+ *
+ * When a new {@link Validator} object is created, initially
+ * this field is set to null.
+ *
+ * @param errorHandler
+ * A new error handler to be set. This parameter can be null.
+ */
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ /**
+ * Gets the current {@link ErrorHandler} set to this {@link Validator}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setErrorHandler(ErrorHandler)} method, or null
+ * if that method has never been called since this {@link Validator}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract ErrorHandler getErrorHandler();
+
+ /**
+ * Sets the {@link LSResourceResolver} to customize
+ * resource resolution while in a validation episode.
+ *
+ *
+ * {@link Validator} uses a {@link LSResourceResolver}
+ * when it needs to locate external resources while a validation,
+ * although exactly what constitutes "locating external resources" is
+ * up to each schema language.
+ *
+ *
+ * When the {@link LSResourceResolver} is null, the implementation will
+ * behave as if the following {@link LSResourceResolver} is set:
+ *
+ * class DumbLSResourceResolver implements {@link LSResourceResolver} {
+ * public {@link org.w3c.dom.ls.LSInput} resolveResource(
+ * String publicId, String systemId, String baseURI) {
+ *
+ * return null; // always return null
+ * }
+ * }
+ *
+ *
+ *
+ * If a {@link LSResourceResolver} throws a {@link RuntimeException}
+ * (or instances of its derived classes),
+ * then the {@link Validator} will abort the parsing and
+ * the caller of the validate method will receive
+ * the same {@link RuntimeException}.
+ *
+ *
+ * When a new {@link Validator} object is created, initially
+ * this field is set to null.
+ *
+ * @param resourceResolver
+ * A new resource resolver to be set. This parameter can be null.
+ */
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ /**
+ * Gets the current {@link LSResourceResolver} set to this {@link Validator}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setResourceResolver(LSResourceResolver)} method, or null
+ * if that method has never been called since this {@link Validator}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract LSResourceResolver getResourceResolver();
+
+
+
+ /**
+ * Look up the value of a feature flag.
+ *
+ *
The feature name is any fully-qualified URI. It is
+ * possible for a {@link Validator} to recognize a feature name but
+ * temporarily be unable to return its value.
+ * Some feature values may be available only in specific
+ * contexts, such as before, during, or after a validation.
+ *
+ *
Implementors are free (and encouraged) to invent their own features,
+ * using names built on their own URIs.
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @return The current value of the feature (true or false).
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link Validator} recognizes the feature name but
+ * cannot determine its value at this time.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ * @see #setFeature(String, boolean)
+ */
+ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null) throw new NullPointerException("the name parameter is null");
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a feature flag.
+ *
+ *
+ * Feature can be used to control the way a {@link Validator}
+ * parses schemas, although {@link Validator}s are not required
+ * to recognize any specific property names.
+ *
+ * The feature name is any fully-qualified URI. It is
+ * possible for a {@link Validator} to expose a feature value but
+ * to be unable to change the current value.
+ * Some feature values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a validation.
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @param value The requested value of the feature (true or false).
+ *
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link Validator} recognizes the feature name but
+ * cannot set the requested value.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ *
+ * @see #getFeature(String)
+ */
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null) throw new NullPointerException("the name parameter is null");
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link Validator} to recognize a property name but
+ * to be unable to change the current value.
+ * Some property values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a validation.
+ *
+ * {@link Validator}s are not required to recognize setting
+ * any specific property names.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @param object The requested value for the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link Validator} recognizes the property name but
+ * cannot set the requested value.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ */
+ public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null) throw new NullPointerException("the name parameter is null");
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Look up the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link Validator} to recognize a property name but
+ * temporarily be unable to return its value.
+ * Some property values may be available only in specific
+ * contexts, such as before, during, or after a validation.
+ *
+ * {@link Validator}s are not required to recognize any specific
+ * property names.
+ *
+ * Implementors are free (and encouraged) to invent their own properties,
+ * using names built on their own URIs.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @return The current value of the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the property name but
+ * cannot determine its value at this time.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ * @see #setProperty(String, Object)
+ */
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null) throw new NullPointerException("the name parameter is null");
+ throw new SAXNotRecognizedException(name);
+ }
+}
diff --git a/java/external/src/javax/xml/validation/ValidatorHandler.java b/java/external/src/javax/xml/validation/ValidatorHandler.java
new file mode 100644
index 0000000..3a59a76
--- /dev/null
+++ b/java/external/src/javax/xml/validation/ValidatorHandler.java
@@ -0,0 +1,449 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.validation;
+
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * Streaming validator that works on SAX stream.
+ *
+ *
+ * A {@link ValidatorHandler} object is a thread-unsafe, non-reentrant object.
+ * In other words, it is the application's responsibility to make
+ * sure that one {@link ValidatorHandler} object is not used from
+ * more than one thread at any given time.
+ *
+ *
+ * {@link ValidatorHandler} checks if the SAX events follow
+ * the set of constraints described in the associated {@link Schema},
+ * and additionally it may modify the SAX events (for example
+ * by adding default values, etc.)
+ *
+ *
+ * {@link ValidatorHandler} extends from {@link ContentHandler},
+ * but it refines the underlying {@link ContentHandler} in
+ * the following way:
+ *
+ * - startElement/endElement events must receive non-null String
+ * for
uri, localName, and qname,
+ * even though SAX allows some of them to be null.
+ * Similarly, the user-specified {@link ContentHandler} will receive non-null
+ * Strings for all three parameters.
+ *
+ * - Applications must ensure that {@link ValidatorHandler}'s
+ * {@link ContentHandler#startPrefixMapping(String,String)} and
+ * {@link ContentHandler#endPrefixMapping(String)} are invoked
+ * properly. Similarly, the user-specified {@link ContentHandler}
+ * will receive startPrefixMapping/endPrefixMapping events.
+ * If the {@link ValidatorHandler} introduces additional namespace
+ * bindings, the user-specified {@link ContentHandler} will receive
+ * additional startPrefixMapping/endPrefixMapping events.
+ *
+ *
- {@link org.xml.sax.Attributes} for the
+ * {@link ContentHandler#startElement(String,String,String,Attributes)} method
+ * may or may not include xmlns* attributes.
+ *
+ *
+ *
+ * A {@link ValidatorHandler} is automatically reset every time
+ * the startDocument method is invoked.
+ *
+ *
Recognized Properties and Features
+ *
+ * This spec defines the following feature that must be recognized
+ * by all {@link ValidatorHandler} implementations.
+ *
+ *
http://xml.org/sax/features/namespace-prefixes
+ *
+ * This feature controls how a {@link ValidatorHandler} introduces
+ * namespace bindings that were not present in the original SAX event
+ * stream.
+ * When this feature is set to true, it must make
+ * sure that the user's {@link ContentHandler} will see
+ * the corresponding xmlns* attribute in
+ * the {@link org.xml.sax.Attributes} object of the
+ * {@link ContentHandler#startElement(String,String,String,Attributes)}
+ * callback. Otherwise, xmlns* attributes must not be
+ * added to {@link org.xml.sax.Attributes} that's passed to the
+ * user-specified {@link ContentHandler}.
+ *
+ * (Note that regardless of this switch, namespace bindings are
+ * always notified to applications through
+ * {@link ContentHandler#startPrefixMapping(String,String)} and
+ * {@link ContentHandler#endPrefixMapping(String)} methods of the
+ * {@link ContentHandler} specified by the user.)
+ *
+ *
+ * Note that this feature does NOT affect the way
+ * a {@link ValidatorHandler} receives SAX events. It merely
+ * changes the way it augments SAX events.
+ *
+ *
This feature is set to false by default.
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class ValidatorHandler implements ContentHandler {
+
+ /**
+ * Constructor for derived classes.
+ *
+ *
+ * The constructor does nothing.
+ *
+ *
+ * Derived classes must create {@link ValidatorHandler} objects that have
+ * null {@link ErrorHandler} and
+ * null {@link LSResourceResolver}.
+ */
+ protected ValidatorHandler() {
+ }
+
+ /**
+ * Sets the {@link ContentHandler} which receives
+ * the augmented validation result.
+ *
+ *
+ * When a {@link ContentHandler} is specified, a
+ * {@link ValidatorHandler} will work as a filter
+ * and basically copy the incoming events to the
+ * specified {@link ContentHandler}.
+ *
+ *
+ * In doing so, a {@link ValidatorHandler} may modify
+ * the events, for example by adding defaulted attributes.
+ *
+ *
+ * A {@link ValidatorHandler} may buffer events to certain
+ * extent, but to allow {@link ValidatorHandler} to be used
+ * by a parser, the following requirement has to be met.
+ *
+ *
+ * - When
+ * {@link ContentHandler#startElement(String, String, String, Attributes)},
+ * {@link ContentHandler#endElement(String, String, String)},
+ * {@link ContentHandler#startDocument()}, or
+ * {@link ContentHandler#endDocument()}
+ * are invoked on a {@link ValidatorHandler},
+ * the same method on the user-specified {@link ContentHandler}
+ * must be invoked for the same event before the callback
+ * returns.
+ *
- {@link ValidatorHandler} may not introduce new elements that
+ * were not present in the input.
+ *
+ *
- {@link ValidatorHandler} may not remove attributes that were
+ * present in the input.
+ *
+ *
+ *
+ * When a callback method on the specified {@link ContentHandler}
+ * throws an exception, the same exception object must be thrown
+ * from the {@link ValidatorHandler}. The {@link ErrorHandler}
+ * should not be notified of such an exception.
+ *
+ *
+ * This method can be called even during a middle of a validation.
+ *
+ * @param receiver
+ * A {@link ContentHandler} or a null value.
+ */
+ public abstract void setContentHandler(ContentHandler receiver);
+
+ /**
+ * Gets the {@link ContentHandler} which receives the
+ * augmented validation result.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #getContentHandler()} method, or null
+ * if that method has never been called since this {@link ValidatorHandler}
+ * has created.
+ *
+ * @see #setContentHandler(ContentHandler)
+ */
+ public abstract ContentHandler getContentHandler();
+
+ /**
+ * Sets the {@link ErrorHandler} to receive errors encountered
+ * during the validation.
+ *
+ *
+ * Error handler can be used to customize the error handling process
+ * during a validation. When an {@link ErrorHandler} is set,
+ * errors found during the validation will be first sent
+ * to the {@link ErrorHandler}.
+ *
+ *
+ * The error handler can abort further validation immediately
+ * by throwing {@link org.xml.sax.SAXException} from the handler. Or for example
+ * it can print an error to the screen and try to continue the
+ * validation by returning normally from the {@link ErrorHandler}
+ *
+ *
+ * If any {@link Throwable} is thrown from an {@link ErrorHandler},
+ * the same {@link Throwable} object will be thrown toward the
+ * root of the call stack.
+ *
+ *
+ * {@link ValidatorHandler} is not allowed to
+ * throw {@link org.xml.sax.SAXException} without first reporting it to
+ * {@link ErrorHandler}.
+ *
+ *
+ * When the {@link ErrorHandler} is null, the implementation will
+ * behave as if the following {@link ErrorHandler} is set:
+ *
+ * class DraconianErrorHandler implements {@link ErrorHandler} {
+ * public void fatalError( {@link org.xml.sax.SAXParseException} e ) throws {@link org.xml.sax.SAXException} {
+ * throw e;
+ * }
+ * public void error( {@link org.xml.sax.SAXParseException} e ) throws {@link org.xml.sax.SAXException} {
+ * throw e;
+ * }
+ * public void warning( {@link org.xml.sax.SAXParseException} e ) throws {@link org.xml.sax.SAXException} {
+ * // noop
+ * }
+ * }
+ *
+ *
+ *
+ * When a new {@link ValidatorHandler} object is created, initially
+ * this field is set to null.
+ *
+ * @param errorHandler
+ * A new error handler to be set. This parameter can be null.
+ */
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ /**
+ * Gets the current {@link ErrorHandler} set to this {@link ValidatorHandler}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setErrorHandler(ErrorHandler)} method, or null
+ * if that method has never been called since this {@link ValidatorHandler}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract ErrorHandler getErrorHandler();
+
+ /**
+ * Sets the {@link LSResourceResolver} to customize
+ * resource resolution while in a validation episode.
+ *
+ *
+ * {@link ValidatorHandler} uses a {@link LSResourceResolver}
+ * when it needs to locate external resources while a validation,
+ * although exactly what constitutes "locating external resources" is
+ * up to each schema language.
+ *
+ *
+ * When the {@link LSResourceResolver} is null, the implementation will
+ * behave as if the following {@link LSResourceResolver} is set:
+ *
+ * class DumbLSResourceResolver implements {@link LSResourceResolver} {
+ * public {@link org.w3c.dom.ls.LSInput} resolveResource(
+ * String publicId, String systemId, String baseURI) {
+ *
+ * return null; // always return null
+ * }
+ * }
+ *
+ *
+ *
+ * If a {@link LSResourceResolver} throws a {@link RuntimeException}
+ * (or instances of its derived classes),
+ * then the {@link ValidatorHandler} will abort the parsing and
+ * the caller of the validate method will receive
+ * the same {@link RuntimeException}.
+ *
+ *
+ * When a new {@link ValidatorHandler} object is created, initially
+ * this field is set to null.
+ *
+ * @param resourceResolver
+ * A new resource resolver to be set. This parameter can be null.
+ */
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ /**
+ * Gets the current {@link LSResourceResolver} set to this {@link ValidatorHandler}.
+ *
+ * @return
+ * This method returns the object that was last set through
+ * the {@link #setResourceResolver(LSResourceResolver)} method, or null
+ * if that method has never been called since this {@link ValidatorHandler}
+ * has created.
+ *
+ * @see #setErrorHandler(ErrorHandler)
+ */
+ public abstract LSResourceResolver getResourceResolver();
+
+ /**
+ * Obtains the {@link TypeInfoProvider} implementation of this
+ * {@link ValidatorHandler}.
+ *
+ *
+ * The obtained {@link TypeInfoProvider} can be queried during a parse
+ * to access the type information determined by the validator.
+ *
+ *
+ * Some schema languages do not define the notion of type,
+ * for those languages, this method may not be supported.
+ * However, to be compliant with this specification, implementations
+ * for W3C XML Schema 1.0 must support this operation.
+ *
+ * @return
+ * null if the validator / schema language does not support
+ * the notion of {@link org.w3c.dom.TypeInfo}.
+ * Otherwise a non-null valid {@link TypeInfoProvider}.
+ */
+ public abstract TypeInfoProvider getTypeInfoProvider();
+
+
+ /**
+ * Look up the value of a feature flag.
+ *
+ *
The feature name is any fully-qualified URI. It is
+ * possible for a {@link ValidatorHandler} to recognize a feature name but
+ * temporarily be unable to return its value.
+ * Some feature values may be available only in specific
+ * contexts, such as before, during, or after a validation.
+ *
+ *
Implementors are free (and encouraged) to invent their own features,
+ * using names built on their own URIs.
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @return The current value of the feature (true or false).
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link ValidatorHandler} recognizes the feature name but
+ * cannot determine its value at this time.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ * @see #setFeature(String, boolean)
+ */
+ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null)
+ throw new NullPointerException();
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a feature flag.
+ *
+ *
+ * Feature can be used to control the way a {@link ValidatorHandler}
+ * parses schemas, although {@link ValidatorHandler}s are not required
+ * to recognize any specific property names.
+ *
+ * The feature name is any fully-qualified URI. It is
+ * possible for a {@link ValidatorHandler} to expose a feature value but
+ * to be unable to change the current value.
+ * Some feature values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a validation.
+ *
+ * @param name The feature name, which is a non-null fully-qualified URI.
+ * @param value The requested value of the feature (true or false).
+ *
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link ValidatorHandler} recognizes the feature name but
+ * cannot set the requested value.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ *
+ * @see #getFeature(String)
+ */
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null)
+ throw new NullPointerException();
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Set the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link ValidatorHandler} to recognize a property name but
+ * to be unable to change the current value.
+ * Some property values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a validation.
+ *
+ * {@link ValidatorHandler}s are not required to recognize setting
+ * any specific property names.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @param object The requested value for the property.
+ *
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * {@link ValidatorHandler} recognizes the property name but
+ * cannot set the requested value.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ */
+ public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null)
+ throw new NullPointerException();
+ throw new SAXNotRecognizedException(name);
+ }
+
+ /**
+ * Look up the value of a property.
+ *
+ * The property name is any fully-qualified URI. It is
+ * possible for a {@link ValidatorHandler} to recognize a property name but
+ * temporarily be unable to return its value.
+ * Some property values may be available only in specific
+ * contexts, such as before, during, or after a validation.
+ *
+ * {@link ValidatorHandler}s are not required to recognize any specific
+ * property names.
+ *
+ * Implementors are free (and encouraged) to invent their own properties,
+ * using names built on their own URIs.
+ *
+ * @param name The property name, which is a non-null fully-qualified URI.
+ * @return The current value of the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the property name but
+ * cannot determine its value at this time.
+ * @throws NullPointerException
+ * When the name parameter is null.
+ * @see #setProperty(String, Object)
+ */
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ if(name==null)
+ throw new NullPointerException();
+ throw new SAXNotRecognizedException(name);
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/SecuritySupport.java b/java/external/src/javax/xml/xpath/SecuritySupport.java
new file mode 100644
index 0000000..601cb31
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/SecuritySupport.java
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import java.net.URL;
+import java.security.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * This class is duplicated for each JAXP subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXP
+ * API.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+class SecuritySupport {
+
+
+ ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) { }
+ return cl;
+ }
+ });
+ }
+
+ String getSystemProperty(final String propName) {
+ return (String)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(propName);
+ }
+ });
+ }
+
+ FileInputStream getFileInputStream(final File file)
+ throws FileNotFoundException
+ {
+ try {
+ return (FileInputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(file);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException)e.getException();
+ }
+ }
+
+ InputStream getURLInputStream(final URL url)
+ throws IOException
+ {
+ try {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return url.openStream();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException)e.getException();
+ }
+ }
+
+ URL getResourceAsURL(final ClassLoader cl,
+ final String name)
+ {
+ return (URL)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ URL url;
+ if (cl == null) {
+ url = ClassLoader.getSystemResource(name);
+ } else {
+ url = cl.getSystemResource(name);
+ }
+ return url;
+ }
+ });
+ }
+
+ Enumeration getResources(final ClassLoader cl,
+ final String name) throws IOException
+ {
+ try{
+ return (Enumeration)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException{
+ Enumeration enumeration;
+ if (cl == null) {
+ enumeration = ClassLoader.getSystemResources(name);
+ } else {
+ enumeration = cl.getSystemResources(name);
+ }
+ return enumeration;
+ }
+ });
+ }catch(PrivilegedActionException e){
+ throw (IOException)e.getException();
+ }
+ }
+
+ InputStream getResourceAsStream(final ClassLoader cl,
+ final String name)
+ {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ InputStream ris;
+ if (cl == null) {
+ ris = ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = cl.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
+ }
+
+ boolean doesFileExist(final File f) {
+ return ((Boolean)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(f.exists());
+ }
+ })).booleanValue();
+ }
+
+}
diff --git a/java/external/src/javax/xml/xpath/XPath.java b/java/external/src/javax/xml/xpath/XPath.java
new file mode 100644
index 0000000..5b22799
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPath.java
@@ -0,0 +1,298 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import org.xml.sax.InputSource;
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * XPath provides access to the XPath evaluation environment and expressions.
+ *
+ *
+ *
+ *
+ * Evaluation of XPath Expressions.
+ *
+ *
+ *
+ *
+ * context
+ *
+ * If a request is made to evaluate the expression in the absence
+ * of a context item, an empty document node will be used for the context.
+ * For the purposes of evaluating XPath expressions, a DocumentFragment
+ * is treated like a Document node.
+ *
+ *
+ *
+ * variables
+ *
+ * If the expression contains a variable reference, its value will be found through the {@link XPathVariableResolver}
+ * set with {@link #setXPathVariableResolver(XPathVariableResolver resolver)}.
+ * An {@link XPathExpressionException} is raised if the variable resolver is undefined or
+ * the resolver returns null for the variable.
+ * The value of a variable must be immutable through the course of any single evaluation.
+ *
+ *
+ *
+ * functions
+ *
+ * If the expression contains a function reference, the function will be found through the {@link XPathFunctionResolver}
+ * set with {@link #setXPathFunctionResolver(XPathFunctionResolver resolver)}.
+ * An {@link XPathExpressionException} is raised if the function resolver is undefined or
+ * the function resolver returns null for the function.
+ *
+ *
+ *
+ * QNames
+ *
+ * QNames in the expression are resolved against the XPath namespace context
+ * set with {@link #setNamespaceContext(NamespaceContext nsContext)}.
+ *
+ *
+ *
+ * result
+ *
+ * This result of evaluating an expression is converted to an instance of the desired return type.
+ * Valid return types are defined in {@link XPathConstants}.
+ * Conversion to the return type follows XPath conversion rules.
+ *
+ *
+ *
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @see XML Path Language (XPath) Version 1.0
+ * @since 1.5
+ */
+public interface XPath {
+
+ /**
+ * Reset this XPath to its original configuration.
+ *
+ * XPath is reset to the same state as when it was created with
+ * {@link XPathFactory#newXPath()}.
+ * reset() is designed to allow the reuse of existing XPaths
+ * thus saving resources associated with the creation of new XPaths.
+ *
+ * The reset XPath is not guaranteed to have the same {@link XPathFunctionResolver}, {@link XPathVariableResolver}
+ * or {@link NamespaceContext} Objects, e.g. {@link Object#equals(Object obj)}.
+ * It is guaranteed to have a functionally equal XPathFunctionResolver, XPathVariableResolver
+ * and NamespaceContext.
+ */
+ public void reset();
+
+ /**
+ * Establish a variable resolver.
+ *
+ * A NullPointerException is thrown if resolver is null.
+ *
+ * @param resolver Variable resolver.
+ *
+ * @throws NullPointerException If resolver is null.
+ */
+ public void setXPathVariableResolver(XPathVariableResolver resolver);
+
+ /**
+ * Return the current variable resolver.
+ *
+ * null is returned in no variable resolver is in effect.
+ *
+ * @return Current variable resolver.
+ */
+ public XPathVariableResolver getXPathVariableResolver();
+
+ /**
+ * Establish a function resolver.
+ *
+ * A NullPointerException is thrown if resolver is null.
+ *
+ * @param resolver XPath function resolver.
+ *
+ * @throws NullPointerException If resolver is null.
+ */
+ public void setXPathFunctionResolver(XPathFunctionResolver resolver);
+
+ /**
+ * Return the current function resolver.
+ *
+ * null is returned in no function resolver is in effect.
+ *
+ * @return Current function resolver.
+ */
+ public XPathFunctionResolver getXPathFunctionResolver();
+
+ /**
+ * Establish a namespace context.
+ *
+ * A NullPointerException is thrown if nsContext is null.
+ *
+ * @param nsContext Namespace context to use.
+ *
+ * @throws NullPointerException If nsContext is null.
+ */
+ public void setNamespaceContext(NamespaceContext nsContext);
+
+ /**
+ * Return the current namespace context.
+ *
+ * null is returned in no namespace context is in effect.
+ *
+ * @return Current Namespace context.
+ */
+ public NamespaceContext getNamespaceContext();
+
+ /**
+ * Compile an XPath expression for later evaluation.
+ *
+ * If expression contains any {@link XPathFunction}s,
+ * they must be available via the {@link XPathFunctionResolver}.
+ * An {@link XPathExpressionException} will be thrown if the XPathFunction
+ * cannot be resovled with the XPathFunctionResolver.
+ *
+ * If expression is null, a NullPointerException is thrown.
+ *
+ * @param expression The XPath expression.
+ *
+ * @return Compiled XPath expression.
+
+ * @throws XPathExpressionException If expression cannot be compiled.
+ * @throws NullPointerException If expression is null.
+ */
+ public XPathExpression compile(String expression)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate an XPath expression in the specified context and return the result as the specified type.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If returnType is not one of the types defined in {@link XPathConstants} (
+ * {@link XPathConstants#NUMBER NUMBER},
+ * {@link XPathConstants#STRING STRING},
+ * {@link XPathConstants#BOOLEAN BOOLEAN},
+ * {@link XPathConstants#NODE NODE} or
+ * {@link XPathConstants#NODESET NODESET})
+ * then an IllegalArgumentException is thrown.
+ *
+ * If a null value is provided for
+ * item, an empty document will be used for the
+ * context.
+ * If expression or returnType is null, then a
+ * NullPointerException is thrown.
+ *
+ * @param expression The XPath expression.
+ * @param item The starting context (node or node list, for example).
+ * @param returnType The desired return type.
+ *
+ * @return Result of evaluating an XPath expression as an Object of returnType.
+ *
+ * @throws XPathExpressionException If expression cannot be evaluated.
+ * @throws IllegalArgumentException If returnType is not one of the types defined in {@link XPathConstants}.
+ * @throws NullPointerException If expression or returnType is null.
+ */
+ public Object evaluate(String expression, Object item, QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate an XPath expression in the specified context and return the result as a String.
+ *
+ * This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a returnType of
+ * {@link XPathConstants#STRING}.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If a null value is provided for
+ * item, an empty document will be used for the
+ * context.
+ * If expression is null, then a NullPointerException is thrown.
+ *
+ * @param expression The XPath expression.
+ * @param item The starting context (node or node list, for example).
+ *
+ * @return The String that is the result of evaluating the expression and
+ * converting the result to a String.
+ *
+ * @throws XPathExpressionException If expression cannot be evaluated.
+ * @throws NullPointerException If expression is null.
+ */
+ public String evaluate(String expression, Object item)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate an XPath expression in the context of the specified InputSource
+ * and return the result as the specified type.
+ *
+ * This method builds a data model for the {@link InputSource} and calls
+ * {@link #evaluate(String expression, Object item, QName returnType)} on the resulting document object.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If returnType is not one of the types defined in {@link XPathConstants},
+ * then an IllegalArgumentException is thrown.
+ *
+ * If expression, source or returnType is null,
+ * then a NullPointerException is thrown.
+ *
+ * @param expression The XPath expression.
+ * @param source The input source of the document to evaluate over.
+ * @param returnType The desired return type.
+ *
+ * @return The Object that encapsulates the result of evaluating the expression.
+ *
+ * @throws XPathExpressionException If expression cannot be evaluated.
+ * @throws IllegalArgumentException If returnType is not one of the types defined in {@link XPathConstants}.
+ * @throws NullPointerException If expression, source or returnType
+ * is null.
+ */
+ public Object evaluate(
+ String expression,
+ InputSource source,
+ QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate an XPath expression in the context of the specified InputSource
+ * and return the result as a String.
+ *
+ * This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
+ * returnType of {@link XPathConstants#STRING}.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If expression or source is null,
+ * then a NullPointerException is thrown.
+ *
+ * @param expression The XPath expression.
+ * @param source The InputSource of the document to evaluate over.
+ *
+ * @return The String that is the result of evaluating the expression and
+ * converting the result to a String.
+ *
+ * @throws XPathExpressionException If expression cannot be evaluated.
+ * @throws NullPointerException If expression or source is null.
+ */
+ public String evaluate(String expression, InputSource source)
+ throws XPathExpressionException;
+}
diff --git a/java/external/src/javax/xml/xpath/XPathConstants.java b/java/external/src/javax/xml/xpath/XPathConstants.java
new file mode 100644
index 0000000..65f8ee8
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathConstants.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * XPath constants.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @see XML Path Language (XPath) Version 1.0
+ * @since 1.5
+ */
+public class XPathConstants {
+
+ /**
+ * Private constructor to prevent instantiation.
+ */
+ private XPathConstants() { }
+
+ /**
+ * The XPath 1.0 number data type.
+ *
+ * Maps to Java {@link Double}.
+ */
+ public static final QName NUMBER = new QName("http://www.w3.org/1999/XSL/Transform", "NUMBER");
+
+ /**
+ * The XPath 1.0 string data type.
+ *
+ * Maps to Java {@link String}.
+ */
+ public static final QName STRING = new QName("http://www.w3.org/1999/XSL/Transform", "STRING");
+
+ /**
+ * The XPath 1.0 boolean data type.
+ *
+ * Maps to Java {@link Boolean}.
+ */
+ public static final QName BOOLEAN = new QName("http://www.w3.org/1999/XSL/Transform", "BOOLEAN");
+
+ /**
+ * The XPath 1.0 NodeSet data type.
+ *
+ * Maps to Java {@link org.w3c.dom.NodeList}.
+ */
+ public static final QName NODESET = new QName("http://www.w3.org/1999/XSL/Transform", "NODESET");
+
+ /**
+ * The XPath 1.0 NodeSet data type.
+ *
+ *
Maps to Java {@link org.w3c.dom.Node}.
+ */
+ public static final QName NODE = new QName("http://www.w3.org/1999/XSL/Transform", "NODE");
+
+ /**
+ * The URI for the DOM object model, "http://java.sun.com/jaxp/xpath/dom".
+ */
+ public static final String DOM_OBJECT_MODEL = "http://java.sun.com/jaxp/xpath/dom";
+}
diff --git a/java/external/src/javax/xml/xpath/XPathException.java b/java/external/src/javax/xml/xpath/XPathException.java
new file mode 100644
index 0000000..17d94a7
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathException.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import java.io.PrintWriter;
+
+/**
+ * XPathException represents a generic XPath exception.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public class XPathException extends Exception {
+
+ private final Throwable cause;
+
+ /**
+ * Stream Unique Identifier.
+ */
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ /**
+ * Constructs a new XPathException with the specified detail message.
+ *
+ * The cause is not initialized.
+ *
+ * If message is null, then a NullPointerException is thrown.
+ *
+ * @param message The detail message.
+ */
+ public XPathException(String message) {
+ super(message);
+ if ( message == null ) {
+ throw new NullPointerException ( "message can't be null");
+ }
+ this.cause = null;
+ }
+
+ /**
+ * Constructs a new XPathException with the specified cause.
+ *
+ * If cause is null, then a NullPointerException is thrown.
+ *
+ * @param cause The cause.
+ *
+ * @throws NullPointerException if cause is null.
+ */
+ public XPathException(Throwable cause) {
+ super();
+ this.cause = cause;
+ if ( cause == null ) {
+ throw new NullPointerException ( "cause can't be null");
+ }
+ }
+
+ public Throwable getCause() {
+ return cause;
+ }
+
+ public void printStackTrace( java.io.PrintStream s ) {
+ if( getCause() != null ) {
+ getCause().printStackTrace(s);
+ s.println("--------------- linked to ------------------");
+ }
+
+ super.printStackTrace(s);
+ }
+
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+
+ public void printStackTrace(PrintWriter s) {
+ if( getCause() != null ) {
+ getCause().printStackTrace(s);
+ s.println("--------------- linked to ------------------");
+ }
+
+ super.printStackTrace(s);
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/XPathExpression.java b/java/external/src/javax/xml/xpath/XPathExpression.java
new file mode 100644
index 0000000..9d4f01a
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathExpression.java
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import org.xml.sax.InputSource;
+import javax.xml.namespace.QName;
+
+/**
+ * XPathExpression provides access to compiled XPath expressions.
+ *
+ *
+ *
+ *
+ * Evaluation of XPath Expressions.
+ *
+ *
+ *
+ *
+ * context
+ *
+ * If a request is made to evaluate the expression in the absence
+ * of a context item, an empty document node will be used for the context.
+ * For the purposes of evaluating XPath expressions, a DocumentFragment
+ * is treated like a Document node.
+ *
+ *
+ *
+ * variables
+ *
+ * If the expression contains a variable reference, its value will be found through the {@link XPathVariableResolver}.
+ * An {@link XPathExpressionException} is raised if the variable resolver is undefined or
+ * the resolver returns null for the variable.
+ * The value of a variable must be immutable through the course of any single evaluation.
+ *
+ *
+ *
+ * functions
+ *
+ * If the expression contains a function reference, the function will be found through the {@link XPathFunctionResolver}.
+ * An {@link XPathExpressionException} is raised if the function resolver is undefined or
+ * the function resolver returns null for the function.
+ *
+ *
+ *
+ * QNames
+ *
+ * QNames in the expression are resolved against the XPath namespace context.
+ *
+ *
+ *
+ * result
+ *
+ * This result of evaluating an expression is converted to an instance of the desired return type.
+ * Valid return types are defined in {@link XPathConstants}.
+ * Conversion to the return type follows XPath conversion rules.
+ *
+ *
+ *
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @see XML Path Language (XPath) Version 1.0, Expressions
+ * @since 1.5
+ */
+public interface XPathExpression {
+
+ /**
+ * Evaluate the compiled XPath expression in the specified context and return the result as the specified type.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If returnType is not one of the types defined in {@link XPathConstants},
+ * then an IllegalArgumentException is thrown.
+ *
+ * If a null value is provided for
+ * item, an empty document will be used for the
+ * context.
+ * If returnType is null, then a NullPointerException is thrown.
+ *
+ * @param item The starting context (node or node list, for example).
+ * @param returnType The desired return type.
+ *
+ * @return The Object that is the result of evaluating the expression and converting the result to
+ * returnType.
+ *
+ * @throws XPathExpressionException If the expression cannot be evaluated.
+ * @throws IllegalArgumentException If returnType is not one of the types defined in {@link XPathConstants}.
+ * @throws NullPointerException If returnType is null.
+ */
+ public Object evaluate(Object item, QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate the compiled XPath expression in the specified context and return the result as a String.
+ *
+ * This method calls {@link #evaluate(Object item, QName returnType)} with a returnType of
+ * {@link XPathConstants#STRING}.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If a null value is provided for
+ * item, an empty document will be used for the
+ * context.
+ *
+ * @param item The starting context (node or node list, for example).
+ *
+ * @return The String that is the result of evaluating the expression and converting the result to a
+ * String.
+ *
+ * @throws XPathExpressionException If the expression cannot be evaluated.
+ */
+ public String evaluate(Object item)
+ throws XPathExpressionException;
+
+ /**
+ *
Evaluate the compiled XPath expression in the context of the specified InputSource and return the result as the
+ * specified type.
+ *
+ * This method builds a data model for the {@link InputSource} and calls
+ * {@link #evaluate(Object item, QName returnType)} on the resulting document object.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If returnType is not one of the types defined in {@link XPathConstants},
+ * then an IllegalArgumentException is thrown.
+ *
+ * If source or returnType is null,
+ * then a NullPointerException is thrown.
+ *
+ * @param source The InputSource of the document to evaluate over.
+ * @param returnType The desired return type.
+ *
+ * @return The Object that is the result of evaluating the expression and converting the result to
+ * returnType.
+ *
+ * @throws XPathExpressionException If the expression cannot be evaluated.
+ * @throws IllegalArgumentException If returnType is not one of the types defined in {@link XPathConstants}.
+ * @throws NullPointerException If source or returnType is null.
+ */
+ public Object evaluate(InputSource source, QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluate the compiled XPath expression in the context of the specified InputSource and return the result as a
+ * String.
+ *
+ * This method calls {@link #evaluate(InputSource source, QName returnType)} with a returnType of
+ * {@link XPathConstants#STRING}.
+ *
+ * See Evaluation of XPath Expressions for context item evaluation,
+ * variable, function and QName resolution and return type conversion.
+ *
+ * If source is null, then a NullPointerException is thrown.
+ *
+ * @param source The InputSource of the document to evaluate over.
+ *
+ * @return The String that is the result of evaluating the expression and converting the result to a
+ * String.
+ *
+ * @throws XPathExpressionException If the expression cannot be evaluated.
+ * @throws NullPointerException If source is null.
+ */
+ public String evaluate(InputSource source)
+ throws XPathExpressionException;
+}
diff --git a/java/external/src/javax/xml/xpath/XPathExpressionException.java b/java/external/src/javax/xml/xpath/XPathExpressionException.java
new file mode 100644
index 0000000..1f234c1
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathExpressionException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+/**
+ * XPathExpressionException represents an error in an XPath expression.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public class XPathExpressionException extends XPathException {
+
+ /**
+ * Stream Unique Identifier.
+ */
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ /**
+ * Constructs a new XPathExpressionException with the specified detail message.
+ *
+ * The cause is not initialized.
+ *
+ * If message is null, then a NullPointerException is thrown.
+ *
+ * @param message The detail message.
+ */
+ public XPathExpressionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new XPathExpressionException with the specified cause.
+ *
+ * If cause is null, then a NullPointerException is thrown.
+ *
+ * @param cause The cause.
+ *
+ * @throws NullPointerException if cause is null.
+ */
+ public XPathExpressionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/XPathFactory.java b/java/external/src/javax/xml/xpath/XPathFactory.java
new file mode 100644
index 0000000..631f474
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFactory.java
@@ -0,0 +1,267 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+/**
+ * An XPathFactory instance can be used to create
+ * {@link javax.xml.xpath.XPath} objects.
+ *
+ *See {@link #newInstance(String uri)} for lookup mechanism.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public abstract class XPathFactory {
+
+
+ /**
+ * The default property name according to the JAXP spec.
+ */
+ public static final String DEFAULT_PROPERTY_NAME = "javax.xml.xpath.XPathFactory";
+
+ /**
+ * Default Object Model URI.
+ */
+ public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom";
+
+ /**
+ * Take care of restrictions imposed by java security model
+ */
+ private static SecuritySupport ss = new SecuritySupport() ;
+
+ /**
+ * Protected constructor as {@link #newInstance()} or {@link #newInstance(String uri)}
+ * should be used to create a new instance of an XPathFactory.
+ */
+ protected XPathFactory() {
+ }
+
+ /**
+ * Get a new XPathFactory instance using the default object model,
+ * {@link #DEFAULT_OBJECT_MODEL_URI},
+ * the W3C DOM.
+ *
+ * This method is functionally equivalent to:
+ *
+ * newInstance(DEFAULT_OBJECT_MODEL_URI)
+ *
+ *
+ * Since the implementation for the W3C DOM is always available, this method will never fail.
+ *
+ * @return Instance of an XPathFactory.
+ */
+ public static final XPathFactory newInstance() {
+
+ try {
+ return newInstance(DEFAULT_OBJECT_MODEL_URI);
+ } catch (XPathFactoryConfigurationException xpathFactoryConfigurationException) {
+ throw new RuntimeException(
+ "XPathFactory#newInstance() failed to create an XPathFactory for the default object model: "
+ + DEFAULT_OBJECT_MODEL_URI
+ + " with the XPathFactoryConfigurationException: "
+ + xpathFactoryConfigurationException.toString()
+ );
+ }
+ }
+
+ /**
+ * Get a new XPathFactory instance using the specified object model.
+ *
+ * To find a XPathFactory object,
+ * this method looks the following places in the following order where "the class loader" refers to the context class loader:
+ *
+ * -
+ * If the system property {@link #DEFAULT_PROPERTY_NAME} + ":uri" is present,
+ * where uri is the parameter to this method, then its value is read as a class name.
+ * The method will try to create a new instance of this class by using the class loader,
+ * and returns it if it is successfully created.
+ *
+ * -
+ * ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for.
+ * If present, the value is processed just like above.
+ *
+ * -
+ * The class loader is asked for service provider provider-configuration files matching
javax.xml.xpath.XPathFactory
+ * in the resource directory META-INF/services.
+ * See the JAR File Specification for file format and parsing rules.
+ * Each potential service provider is required to implement the method:
+ *
+ * {@link #isObjectModelSupported(String objectModel)}
+ *
+ * The first service provider found in class loader order that supports the specified object model is returned.
+ *
+ * -
+ * Platform default
XPathFactory is located in a platform specific way.
+ * There must be a platform default XPathFactory for the W3C DOM, i.e. {@link #DEFAULT_OBJECT_MODEL_URI}.
+ *
+ *
+ * If everything fails, an XPathFactoryConfigurationException will be thrown.
+ *
+ * Tip for Trouble-shooting:
+ * See {@link java.util.Properties#load(java.io.InputStream)} for exactly how a property file is parsed.
+ * In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it.
+ * For example:
+ *
+ * http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
+ *
+ *
+ * @param uri Identifies the underlying object model.
+ * The specification only defines the URI {@link #DEFAULT_OBJECT_MODEL_URI},
+ * http://java.sun.com/jaxp/xpath/dom for the W3C DOM,
+ * the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.
+ *
+ * @return Instance of an XPathFactory.
+ *
+ * @throws XPathFactoryConfigurationException If the specified object model is unavailable.
+ * @throws NullPointerException If uri is null.
+ * @throws IllegalArgumentException If uri.length() == 0.
+ */
+ public static final XPathFactory newInstance(final String uri)
+ throws XPathFactoryConfigurationException {
+
+ if (uri == null) {
+ throw new NullPointerException(
+ "XPathFactory#newInstance(String uri) cannot be called with uri == null"
+ );
+ }
+
+ if (uri.length() == 0) {
+ throw new IllegalArgumentException(
+ "XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
+ );
+ }
+
+ ClassLoader classLoader = ss.getContextClassLoader();
+
+ if (classLoader == null) {
+ //use the current class loader
+ classLoader = XPathFactory.class.getClassLoader();
+ }
+
+ XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
+
+ if (xpathFactory == null) {
+ throw new XPathFactoryConfigurationException(
+ "No XPathFctory implementation found for the object model: "
+ + uri
+ );
+ }
+
+ return xpathFactory;
+ }
+
+ /**
+ * Is specified object model supported by this XPathFactory?
+ *
+ * @param objectModel Specifies the object model which the returned XPathFactory will understand.
+ *
+ * @return true if XPathFactory supports objectModel, else false.
+ *
+ * @throws NullPointerException If objectModel is null.
+ * @throws IllegalArgumentException If objectModel.length() == 0.
+ */
+ public abstract boolean isObjectModelSupported(String objectModel);
+
+ /**
+ * Set a feature for this XPathFactory and XPaths created by this factory.
+ *
+ *
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * An {@link XPathFactoryConfigurationException} is thrown if this XPathFactory or the XPaths
+ * it creates cannot support the feature.
+ * It is possible for an XPathFactory to expose a feature value but be unable to change its state.
+ *
+ *
+ *
+ * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
+ * When the feature is true, any reference to an external function is an error.
+ * Under these conditions, the implementation must not call the {@link XPathFunctionResolver}
+ * and must throw an {@link XPathFunctionException}.
+ *
+ *
+ * @param name Feature name.
+ * @param value Is feature state true or false.
+ *
+ * @throws XPathFactoryConfigurationException if this XPathFactory or the XPaths
+ * it creates cannot support this feature.
+ * @throws NullPointerException if name is null.
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws XPathFactoryConfigurationException;
+
+ /**
+ * Get the state of the named feature.
+ *
+ *
+ * Feature names are fully qualified {@link java.net.URI}s.
+ * Implementations may define their own features.
+ * An {@link XPathFactoryConfigurationException} is thrown if this XPathFactory or the XPaths
+ * it creates cannot support the feature.
+ * It is possible for an XPathFactory to expose a feature value but be unable to change its state.
+ *
+ *
+ * @param name Feature name.
+ *
+ * @return State of the named feature.
+ *
+ * @throws XPathFactoryConfigurationException if this XPathFactory or the XPaths
+ * it creates cannot support this feature.
+ * @throws NullPointerException if name is null.
+ */
+ public abstract boolean getFeature(String name)
+ throws XPathFactoryConfigurationException;
+
+ /**
+ * Establish a default variable resolver.
+ *
+ * Any XPath objects constructed from this factory will use
+ * the specified resolver by default.
+ *
+ * A NullPointerException is thrown if resolver is null.
+ *
+ * @param resolver Variable resolver.
+ *
+ * @throws NullPointerException If resolver is null.
+ */
+ public abstract void setXPathVariableResolver(XPathVariableResolver resolver);
+
+ /**
+ * Establish a default function resolver.
+ *
+ * Any XPath objects constructed from this factory will use
+ * the specified resolver by default.
+ *
+ * A NullPointerException is thrown if resolver is null.
+ *
+ * @param resolver XPath function resolver.
+ *
+ * @throws NullPointerException If resolver is null.
+ */
+ public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver);
+
+ /**
+ * Return a new XPath using the underlying object
+ * model determined when the XPathFactory was instantiated.
+ *
+ * @return New instance of an XPath.
+ */
+ public abstract XPath newXPath();
+}
diff --git a/java/external/src/javax/xml/xpath/XPathFactoryConfigurationException.java b/java/external/src/javax/xml/xpath/XPathFactoryConfigurationException.java
new file mode 100644
index 0000000..ab2ac69
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFactoryConfigurationException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+/**
+ * XPathFactoryConfigurationException represents a configuration error in a XPathFactory environment.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public class XPathFactoryConfigurationException extends XPathException {
+
+ /**
+ * Stream Unique Identifier.
+ */
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ /**
+ * Constructs a new XPathFactoryConfigurationException with the specified detail message.
+ *
+ * The cause is not initialized.
+ *
+ * If message is null, then a NullPointerException is thrown.
+ *
+ * @param message The detail message.
+ */
+ public XPathFactoryConfigurationException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new XPathFactoryConfigurationException with the specified cause.
+ *
+ * If cause is null, then a NullPointerException is thrown.
+ *
+ * @param cause The cause.
+ *
+ * @throws NullPointerException if cause is null.
+ */
+ public XPathFactoryConfigurationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/XPathFactoryFinder.java b/java/external/src/javax/xml/xpath/XPathFactoryFinder.java
new file mode 100644
index 0000000..0e5bd10
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFactoryFinder.java
@@ -0,0 +1,372 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+
+/**
+ * Implementation of {@link XPathFactory#newInstance(String)}.
+ *
+ * @author Kohsuke Kawaguchi
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+class XPathFactoryFinder {
+
+ private static SecuritySupport ss = new SecuritySupport() ;
+ /** debug support code. */
+ private static boolean debug = false;
+ static {
+ // Use try/catch block to support applets
+ try {
+ debug = ss.getSystemProperty("jaxp.debug") != null;
+ } catch (Exception _) {
+ debug = false;
+ }
+ }
+
+ /**
+ * Cache properties for performance.
+ */
+ private static Properties cacheProps = new Properties();
+
+ /**
+ * First time requires initialization overhead.
+ */
+ private static boolean firstTime = true;
+
+ /**
+ * Conditional debug printing.
+ *
+ * @param msg to print
+ */
+ private static void debugPrintln(String msg) {
+ if (debug) {
+ System.err.println("JAXP: " + msg);
+ }
+ }
+
+ /**
+ * ClassLoader to use to find SchemaFactory.
+ */
+ private final ClassLoader classLoader;
+
+ /**
+ * Constructor that specifies ClassLoader to use
+ * to find SchemaFactory.
+ *
+ * @param loader
+ * to be used to load resource, {@link SchemaFactory}, and
+ * {@link SchemaFactoryLoader} implementations during
+ * the resolution process.
+ * If this parameter is null, the default system class loader
+ * will be used.
+ */
+ public XPathFactoryFinder(ClassLoader loader) {
+ this.classLoader = loader;
+ if( debug ) {
+ debugDisplayClassLoader();
+ }
+ }
+
+ private void debugDisplayClassLoader() {
+ try {
+ if( classLoader == ss.getContextClassLoader() ) {
+ debugPrintln("using thread context class loader ("+classLoader+") for search");
+ return;
+ }
+ } catch( Throwable _ ) {
+ ; // getContextClassLoader() undefined in JDK1.1
+ }
+
+ if( classLoader==ClassLoader.getSystemClassLoader() ) {
+ debugPrintln("using system class loader ("+classLoader+") for search");
+ return;
+ }
+
+ debugPrintln("using class loader ("+classLoader+") for search");
+ }
+
+ /**
+ * Creates a new {@link XPathFactory} object for the specified
+ * schema language.
+ *
+ * @param uri
+ * Identifies the underlying object model.
+ *
+ * @return null if the callee fails to create one.
+ *
+ * @throws NullPointerException
+ * If the parameter is null.
+ */
+ public XPathFactory newFactory(String uri) {
+ if(uri==null) throw new NullPointerException();
+ XPathFactory f = _newFactory(uri);
+ if (f != null) {
+ debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
+ } else {
+ debugPrintln("unable to find a factory for " + uri);
+ }
+ return f;
+ }
+
+ /**
+ * Lookup a {@link XPathFactory} for the given object model.
+ *
+ * @param uri identifies the object model.
+ *
+ * @return {@link XPathFactory} for the given object model.
+ */
+ private XPathFactory _newFactory(String uri) {
+ XPathFactory sf;
+
+ String propertyName = SERVICE_CLASS.getName() + ":" + uri;
+
+ // system property look up
+ try {
+ debugPrintln("Looking up system property '"+propertyName+"'" );
+ String r = ss.getSystemProperty(propertyName);
+ if(r!=null) {
+ debugPrintln("The value is '"+r+"'");
+ sf = createInstance(r);
+ if(sf!=null) return sf;
+ } else
+ debugPrintln("The property is undefined.");
+ } catch( Throwable t ) {
+ if( debug ) {
+ debugPrintln("failed to look up system property '"+propertyName+"'" );
+ t.printStackTrace();
+ }
+ }
+
+ String javah = ss.getSystemProperty( "java.home" );
+ String configFile = javah + File.separator +
+ "lib" + File.separator + "jaxp.properties";
+
+ String factoryClassName = null ;
+
+ // try to read from $java.home/lib/jaxp.properties
+ try {
+ if(firstTime){
+ synchronized(cacheProps){
+ if(firstTime){
+ File f=new File( configFile );
+ firstTime = false;
+ if(ss.doesFileExist(f)){
+ debugPrintln("Read properties file " + f);
+ cacheProps.load(ss.getFileInputStream(f));
+ }
+ }
+ }
+ }
+ factoryClassName = cacheProps.getProperty(propertyName);
+ debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
+
+ if (factoryClassName != null) {
+ sf = createInstance(factoryClassName);
+ if(sf != null){
+ return sf;
+ }
+ }
+ } catch (Exception ex) {
+ if (debug) {
+ ex.printStackTrace();
+ }
+ }
+
+ // try META-INF/services files
+ Iterator sitr = createServiceFileIterator();
+ while(sitr.hasNext()) {
+ URL resource = (URL)sitr.next();
+ debugPrintln("looking into " + resource);
+ try {
+ //sf = loadFromProperty(uri,resource.toExternalForm(),resource.openStream());
+ sf = loadFromProperty(uri,resource.toExternalForm(),ss.getURLInputStream(resource));
+ if(sf!=null) return sf;
+ } catch(IOException e) {
+ if( debug ) {
+ debugPrintln("failed to read "+resource);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ // platform default
+ if(uri.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) {
+ debugPrintln("attempting to use the platform default W3C DOM XPath lib");
+ return createInstance("org.apache.xpath.jaxp.XPathFactoryImpl");
+ }
+
+ debugPrintln("all things were tried, but none was found. bailing out.");
+ return null;
+ }
+
+ /**
+ * Creates an instance of the specified and returns it.
+ *
+ * @param className
+ * fully qualified class name to be instanciated.
+ *
+ * @return null
+ * if it fails. Error messages will be printed by this method.
+ */
+ private XPathFactory createInstance( String className ) {
+ try {
+ debugPrintln("instanciating "+className);
+ Class clazz;
+ if( classLoader!=null )
+ clazz = classLoader.loadClass(className);
+ else
+ clazz = Class.forName(className);
+ if(debug) debugPrintln("loaded it from "+which(clazz));
+ Object o = clazz.newInstance();
+
+ if( o instanceof XPathFactory )
+ return (XPathFactory)o;
+
+ debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
+ } catch( Throwable t ) {
+ debugPrintln("failed to instanciate "+className);
+ if(debug) t.printStackTrace();
+ }
+ return null;
+ }
+
+ /** Iterator that lazily computes one value and returns it. */
+ private static abstract class SingleIterator implements Iterator {
+ private boolean seen = false;
+
+ public final void remove() { throw new UnsupportedOperationException(); }
+ public final boolean hasNext() { return !seen; }
+ public final Object next() {
+ if(seen) throw new NoSuchElementException();
+ seen = true;
+ return value();
+ }
+
+ protected abstract Object value();
+ }
+
+ /**
+ * Looks up a value in a property file
+ * while producing all sorts of debug messages.
+ *
+ * @return null
+ * if there was an error.
+ */
+ private XPathFactory loadFromProperty( String keyName, String resourceName, InputStream in )
+ throws IOException {
+ debugPrintln("Reading "+resourceName );
+
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ String factoryClassName = props.getProperty(keyName);
+ if(factoryClassName != null){
+ debugPrintln("found "+keyName+" = " + factoryClassName);
+ return createInstance(factoryClassName);
+ } else {
+ debugPrintln(keyName+" is not in the property file");
+ return null;
+ }
+ }
+
+ /**
+ * Returns an {@link Iterator} that enumerates all
+ * the META-INF/services files that we care.
+ */
+ private Iterator createServiceFileIterator() {
+ if (classLoader == null) {
+ return new SingleIterator() {
+ protected Object value() {
+ ClassLoader classLoader = XPathFactoryFinder.class.getClassLoader();
+ return ss.getResourceAsURL(classLoader, SERVICE_ID);
+ //return (ClassLoader.getSystemResource( SERVICE_ID ));
+ }
+ };
+ } else {
+ try {
+ //final Enumeration e = classLoader.getResources(SERVICE_ID);
+ final Enumeration e = ss.getResources(classLoader, SERVICE_ID);
+ if(!e.hasMoreElements()) {
+ debugPrintln("no "+SERVICE_ID+" file was found");
+ }
+
+ // wrap it into an Iterator.
+ return new Iterator() {
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext() {
+ return e.hasMoreElements();
+ }
+
+ public Object next() {
+ return e.nextElement();
+ }
+ };
+ } catch (IOException e) {
+ debugPrintln("failed to enumerate resources "+SERVICE_ID);
+ if(debug) e.printStackTrace();
+ return new ArrayList().iterator(); // empty iterator
+ }
+ }
+ }
+
+ private static final Class SERVICE_CLASS = XPathFactory.class;
+ private static final String SERVICE_ID = "META-INF/services/" + SERVICE_CLASS.getName();
+
+
+
+ private static String which( Class clazz ) {
+ return which( clazz.getName(), clazz.getClassLoader() );
+ }
+
+ /**
+ * Search the specified classloader for the given classname.
+ *
+ * @param classname the fully qualified name of the class to search for
+ * @param loader the classloader to search
+ *
+ * @return the source location of the resource, or null if it wasn't found
+ */
+ private static String which(String classname, ClassLoader loader) {
+
+ String classnameAsResource = classname.replace('.', '/') + ".class";
+
+ if( loader==null ) loader = ClassLoader.getSystemClassLoader();
+
+ //URL it = loader.getResource(classnameAsResource);
+ URL it = ss.getResourceAsURL(loader, classnameAsResource);
+ if (it != null) {
+ return it.toString();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/XPathFunction.java b/java/external/src/javax/xml/xpath/XPathFunction.java
new file mode 100644
index 0000000..32424a8
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFunction.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import java.util.List;
+
+/**
+ * XPathFunction provides access to XPath functions.
+ *
+ * Functions are identified by QName and arity in XPath.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public interface XPathFunction {
+ /**
+ * Evaluate the function with the specified arguments.
+ *
+ * To the greatest extent possible, side-effects should be avoided in the
+ * definition of extension functions. The implementation evaluating an
+ * XPath expression is under no obligation to call extension functions in
+ * any particular order or any particular number of times.
+ *
+ * @param args The arguments, null is a valid value.
+ *
+ * @return The result of evaluating the XPath function as an Object.
+ *
+ * @throws XPathFunctionException If args cannot be evaluated with this XPath function.
+ */
+ public Object evaluate(List args)
+ throws XPathFunctionException;
+}
+
diff --git a/java/external/src/javax/xml/xpath/XPathFunctionException.java b/java/external/src/javax/xml/xpath/XPathFunctionException.java
new file mode 100644
index 0000000..1ed82db
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFunctionException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+/**
+ * XPathFunctionException represents an error with an XPath function.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public class XPathFunctionException extends XPathExpressionException {
+
+ /**
+ * Stream Unique Identifier.
+ */
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ /**
+ * Constructs a new XPathFunctionException with the specified detail message.
+ *
+ * The cause is not initialized.
+ *
+ * If message is null, then a NullPointerException is thrown.
+ *
+ * @param message The detail message.
+ */
+ public XPathFunctionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new XPathFunctionException with the specified cause.
+ *
+ * If cause is null, then a NullPointerException is thrown.
+ *
+ * @param cause The cause.
+ *
+ * @throws NullPointerException if cause is null.
+ */
+ public XPathFunctionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/java/external/src/javax/xml/xpath/XPathFunctionResolver.java b/java/external/src/javax/xml/xpath/XPathFunctionResolver.java
new file mode 100644
index 0000000..7c957b3
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathFunctionResolver.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * XPathFunctionResolver provides access to the set of user defined XPathFunctions.
+ *
+ * XPath functions are resolved by name and arity.
+ * The resolver is not needed for XPath built-in functions and the resolver
+ * cannot be used to override those functions.
+ *
+ * In particular, the resolver is only called for functions in an another
+ * namespace (functions with an explicit prefix). This means that you cannot
+ * use the XPathFunctionResolver to implement specifications
+ * like XML-Signature Syntax
+ * and Processing which extend the function library of XPath 1.0 in the
+ * same namespace. This is a consequence of the design of the resolver.
+ *
+ * If you wish to implement additional built-in functions, you will have to
+ * extend the underlying implementation directly.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @see XML Path Language (XPath) Version 1.0, Core Function Library
+ * @since 1.5
+ */
+public interface XPathFunctionResolver {
+ /**
+ * Find a function in the set of available functions.
+ *
+ * If functionName or arity is null, then a NullPointerException is thrown.
+ *
+ * @param functionName The function name.
+ * @param arity The number of arguments that the returned function must accept.
+ *
+ * @return The function or null if no function named functionName with arity arguments exists.
+ *
+ * @throws NullPointerException If functionName or arity is null.
+ */
+ public XPathFunction resolveFunction(QName functionName, int arity);
+}
diff --git a/java/external/src/javax/xml/xpath/XPathVariableResolver.java b/java/external/src/javax/xml/xpath/XPathVariableResolver.java
new file mode 100644
index 0000000..782b916
--- /dev/null
+++ b/java/external/src/javax/xml/xpath/XPathVariableResolver.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+// $Id$
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * XPathVariableResolver provides access to the set of user defined XPath variables.
+ *
+ * The XPathVariableResolver and the XPath evaluator must adhere to a contract that
+ * cannot be directly enforced by the API. Although variables may be mutable,
+ * that is, an application may wish to evaluate the same XPath expression more
+ * than once with different variable values, in the course of evaluating any
+ * single XPath expression, a variable's value must be immutable.
+ *
+ * @author Norman Walsh
+ * @author Jeff Suttor
+ * @version $Revision$, $Date$
+ * @since 1.5
+ */
+public interface XPathVariableResolver {
+ /**
+ * Find a variable in the set of available variables.
+ *
+ * If variableName is null, then a NullPointerException is thrown.
+ *
+ * @param variableName The QName of the variable name.
+ *
+ * @return The variables value, or null if no variable named variableName
+ * exists. The value returned must be of a type appropriate for the underlying object model.
+ *
+ * @throws NullPointerException If variableName is null.
+ */
+ public Object resolveVariable(QName variableName);
+}