Initial revision
From-SVN: r102074
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/* ContentHandler2.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.aelfred2;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Extension to the SAX ContentHandler interface to report parsing events
|
||||
* and parameters required by DOM Level 3 but not supported by SAX.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public interface ContentHandler2
|
||||
extends ContentHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Reports the XML declaration.
|
||||
* @param version the value of the version attribute in the XML
|
||||
* declaration
|
||||
* @param encoding the encoding specified in the XML declaration, if any
|
||||
* @param standalone the standalone attribute from the XML declaration
|
||||
* @param inputEncoding the encoding of the XML input
|
||||
*/
|
||||
void xmlDecl(String version, String encoding, boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/* JAXPFactory.java --
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.aelfred2;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.xml.sax.Parser;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
import org.xml.sax.helpers.XMLReaderAdapter;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Configurable factory to create an Ælfred2 JAXP parser; required
|
||||
* to bootstrap using JAXP. You should use SAX2 directly where possible,
|
||||
* rather than through JAXP, since that gives you better control.
|
||||
* This class would normally be configured as a platform default factory.
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public final class JAXPFactory
|
||||
extends SAXParserFactory
|
||||
{
|
||||
|
||||
private Hashtable flags = new Hashtable();
|
||||
|
||||
/**
|
||||
* Constructs a factory which normally returns a non-validating
|
||||
* parser.
|
||||
*/
|
||||
public JAXPFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public SAXParser newSAXParser()
|
||||
throws ParserConfigurationException, SAXException
|
||||
{
|
||||
JaxpParser jaxp = new JaxpParser();
|
||||
Enumeration e = flags.keys();
|
||||
XMLReader parser = jaxp.getXMLReader();
|
||||
|
||||
parser.setFeature(SAXDriver.FEATURE + "namespaces",
|
||||
isNamespaceAware());
|
||||
parser.setFeature(SAXDriver.FEATURE + "validation",
|
||||
isValidating());
|
||||
// that makes SAX2 feature flags trump JAXP
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String uri = (String) e.nextElement();
|
||||
Boolean value = (Boolean) flags.get(uri);
|
||||
parser.setFeature(uri, value.booleanValue());
|
||||
}
|
||||
|
||||
return jaxp;
|
||||
}
|
||||
|
||||
// yes, this "feature transfer" mechanism doesn't play well
|
||||
|
||||
public void setFeature(String name, boolean value)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException,
|
||||
SAXNotSupportedException
|
||||
{
|
||||
try
|
||||
{
|
||||
// force "early" detection of errors where possible
|
||||
// (flags can't necessarily be set before parsing)
|
||||
new JaxpParser().getXMLReader().setFeature(name, value);
|
||||
|
||||
flags.put(name, new Boolean(value));
|
||||
}
|
||||
catch (SAXNotRecognizedException e)
|
||||
{
|
||||
throw new SAXNotRecognizedException(name);
|
||||
}
|
||||
catch (SAXNotSupportedException e)
|
||||
{
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ParserConfigurationException(e.getClass().getName()
|
||||
+ ": "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFeature(String name)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException,
|
||||
SAXNotSupportedException
|
||||
{
|
||||
Boolean value = (Boolean) flags.get(name);
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
return value.booleanValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
return new JaxpParser().getXMLReader().getFeature(name);
|
||||
}
|
||||
catch (SAXNotRecognizedException e)
|
||||
{
|
||||
throw new SAXNotRecognizedException(name);
|
||||
}
|
||||
catch (SAXNotSupportedException e)
|
||||
{
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ParserConfigurationException(e.getClass().getName()
|
||||
+ ": "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class JaxpParser
|
||||
extends SAXParser
|
||||
{
|
||||
|
||||
private XmlReader ae2 = new XmlReader();
|
||||
private XMLReaderAdapter parser = null;
|
||||
|
||||
JaxpParser()
|
||||
{
|
||||
}
|
||||
|
||||
public void setProperty(String id, Object value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
ae2.setProperty(id, value);
|
||||
}
|
||||
|
||||
public Object getProperty(String id)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
return ae2.getProperty(id);
|
||||
}
|
||||
|
||||
public Parser getParser()
|
||||
throws SAXException
|
||||
{
|
||||
if (parser == null)
|
||||
{
|
||||
parser = new XMLReaderAdapter(ae2);
|
||||
}
|
||||
return parser;
|
||||
}
|
||||
|
||||
public XMLReader getXMLReader ()
|
||||
throws SAXException
|
||||
{
|
||||
return ae2;
|
||||
}
|
||||
|
||||
public boolean isNamespaceAware()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ae2.getFeature(SAXDriver.FEATURE + "namespaces");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidating()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ae2.getFeature(SAXDriver.FEATURE + "validation");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO isXIncludeAware()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,374 @@
|
||||
/* XmlReader.java --
|
||||
Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.aelfred2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.xml.sax.*;
|
||||
import org.xml.sax.ext.*;
|
||||
|
||||
import gnu.xml.pipeline.EventFilter;
|
||||
import gnu.xml.pipeline.ValidationConsumer;
|
||||
|
||||
|
||||
/**
|
||||
* This SAX2 parser optionally layers a validator over the Ælfred2
|
||||
* SAX2 parser. While this will not evaluate every XML validity constraint,
|
||||
* it does support all the validity constraints that are of any real utility
|
||||
* outside the strict SGML-compatible world. See the documentation for the
|
||||
* SAXDriver class for information about the SAX2 features and properties
|
||||
* that are supported, and documentation for the ValidationConsumer for
|
||||
* information about what validity constraints may not be supported.
|
||||
* (Ælfred2 tests some of those, even in non-validating mode, to
|
||||
* achieve better conformance.)
|
||||
*
|
||||
* <p> Note that due to its internal construction, you can't change most
|
||||
* handlers until parse() returns. This diverges slightly from SAX, which
|
||||
* expects later binding to be supported. Early binding involves less
|
||||
* runtime overhead, which is an issue for event pipelines as used inside
|
||||
* this parser. Rather than relying on the parser to handle late binding
|
||||
* to your own handlers, do it yourself.
|
||||
*
|
||||
* @see SAXDriver
|
||||
* @see gnu.xml.pipeline.ValidationConsumer
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public final class XmlReader
|
||||
implements XMLReader
|
||||
{
|
||||
|
||||
static class FatalErrorHandler
|
||||
extends DefaultHandler2
|
||||
{
|
||||
|
||||
public void error(SAXParseException e)
|
||||
throws SAXException
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SAXDriver aelfred2 = new SAXDriver();
|
||||
private EventFilter filter = new EventFilter();
|
||||
private boolean isValidating;
|
||||
private boolean active;
|
||||
|
||||
/**
|
||||
* Constructs a SAX Parser.
|
||||
*/
|
||||
public XmlReader()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a SAX Parser, optionally treating validity errors
|
||||
* as if they were fatal errors.
|
||||
*/
|
||||
public XmlReader(boolean invalidIsFatal)
|
||||
{
|
||||
if (invalidIsFatal)
|
||||
{
|
||||
setErrorHandler(new FatalErrorHandler());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Returns the object used to report the logical
|
||||
* content of an XML document.
|
||||
*/
|
||||
public ContentHandler getContentHandler()
|
||||
{
|
||||
return filter.getContentHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Assigns the object used to report the logical
|
||||
* content of an XML document.
|
||||
* @exception IllegalStateException if called mid-parse
|
||||
*/
|
||||
public void setContentHandler(ContentHandler handler)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new IllegalStateException("already parsing");
|
||||
}
|
||||
filter.setContentHandler(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Returns the object used to process declarations related
|
||||
* to notations and unparsed entities.
|
||||
*/
|
||||
public DTDHandler getDTDHandler()
|
||||
{
|
||||
return filter.getDTDHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b> Assigns DTD handler
|
||||
* @exception IllegalStateException if called mid-parse
|
||||
*/
|
||||
public void setDTDHandler(DTDHandler handler)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new IllegalStateException("already parsing");
|
||||
}
|
||||
filter.setDTDHandler(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Returns the object used when resolving external
|
||||
* entities during parsing (both general and parameter entities).
|
||||
*/
|
||||
public EntityResolver getEntityResolver()
|
||||
{
|
||||
return aelfred2.getEntityResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b> Assigns parser's entity resolver
|
||||
*/
|
||||
public void setEntityResolver(EntityResolver handler)
|
||||
{
|
||||
aelfred2.setEntityResolver(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Returns the object used to receive callbacks for XML
|
||||
* errors of all levels (fatal, nonfatal, warning); this is never null;
|
||||
*/
|
||||
public ErrorHandler getErrorHandler()
|
||||
{
|
||||
return aelfred2.getErrorHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b> Assigns error handler
|
||||
* @exception IllegalStateException if called mid-parse
|
||||
*/
|
||||
public void setErrorHandler(ErrorHandler handler)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new IllegalStateException("already parsing");
|
||||
}
|
||||
aelfred2.setErrorHandler(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Assigns the specified property.
|
||||
* @exception IllegalStateException if called mid-parse
|
||||
*/
|
||||
public void setProperty(String propertyId, Object value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new IllegalStateException("already parsing");
|
||||
}
|
||||
if (getProperty(propertyId) != value)
|
||||
{
|
||||
filter.setProperty(propertyId, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Returns the specified property.
|
||||
*/
|
||||
public Object getProperty(String propertyId)
|
||||
throws SAXNotRecognizedException
|
||||
{
|
||||
if ((SAXDriver.PROPERTY + "declaration-handler").equals(propertyId)
|
||||
|| (SAXDriver.PROPERTY + "lexical-handler").equals(propertyId))
|
||||
{
|
||||
return filter.getProperty(propertyId);
|
||||
}
|
||||
throw new SAXNotRecognizedException(propertyId);
|
||||
}
|
||||
|
||||
private void forceValidating()
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
aelfred2.setFeature(SAXDriver.FEATURE + "namespace-prefixes",
|
||||
true);
|
||||
aelfred2.setFeature(SAXDriver.FEATURE + "external-general-entities",
|
||||
true);
|
||||
aelfred2.setFeature(SAXDriver.FEATURE + "external-parameter-entities",
|
||||
true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Sets the state of features supported in this parser.
|
||||
* Note that this parser requires reporting of namespace prefixes when
|
||||
* validating.
|
||||
*/
|
||||
public void setFeature(String featureId, boolean state)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
boolean value = getFeature(featureId);
|
||||
|
||||
if (state == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((SAXDriver.FEATURE + "validation").equals(featureId))
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new SAXNotSupportedException("already parsing");
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
forceValidating();
|
||||
}
|
||||
isValidating = state;
|
||||
}
|
||||
else
|
||||
{
|
||||
aelfred2.setFeature(featureId, state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX2</b>: Tells whether this parser supports the specified feature.
|
||||
* At this time, this directly parallels the underlying SAXDriver,
|
||||
* except that validation is optionally supported.
|
||||
*
|
||||
* @see SAXDriver
|
||||
*/
|
||||
public boolean getFeature(String featureId)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if ((SAXDriver.FEATURE + "validation").equals(featureId))
|
||||
{
|
||||
return isValidating;
|
||||
}
|
||||
|
||||
return aelfred2.getFeature(featureId);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b>: Sets the locale used for diagnostics; currently,
|
||||
* only locales using the English language are supported.
|
||||
* @param locale The locale for which diagnostics will be generated
|
||||
*/
|
||||
public void setLocale(Locale locale)
|
||||
throws SAXException
|
||||
{
|
||||
aelfred2.setLocale(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b>: Preferred API to parse an XML document, using a
|
||||
* system identifier (URI).
|
||||
*/
|
||||
public void parse(String systemId)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
parse(new InputSource(systemId));
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>SAX1</b>: Underlying API to parse an XML document, used
|
||||
* directly when no URI is available. When this is invoked,
|
||||
* and the parser is set to validate, some features will be
|
||||
* automatically reset to appropriate values: for reporting
|
||||
* namespace prefixes, and incorporating external entities.
|
||||
*
|
||||
* @param source The XML input source.
|
||||
*
|
||||
* @exception IllegalStateException if called mid-parse
|
||||
* @exception SAXException The handlers may throw any SAXException,
|
||||
* and the parser normally throws SAXParseException objects.
|
||||
* @exception IOException IOExceptions are normally through through
|
||||
* the parser if there are problems reading the source document.
|
||||
*/
|
||||
public void parse(InputSource source)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
EventFilter next;
|
||||
boolean nsdecls;
|
||||
|
||||
synchronized (aelfred2)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
throw new IllegalStateException("already parsing");
|
||||
}
|
||||
active = true;
|
||||
}
|
||||
|
||||
// set up the output pipeline
|
||||
if (isValidating)
|
||||
{
|
||||
forceValidating();
|
||||
next = new ValidationConsumer(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
next = filter;
|
||||
}
|
||||
|
||||
// connect pipeline and error handler
|
||||
// don't let _this_ call to bind() affect xmlns* attributes
|
||||
nsdecls = aelfred2.getFeature(SAXDriver.FEATURE + "namespace-prefixes");
|
||||
EventFilter.bind(aelfred2, next);
|
||||
if (!nsdecls)
|
||||
{
|
||||
aelfred2.setFeature(SAXDriver.FEATURE + "namespace-prefixes",
|
||||
false);
|
||||
}
|
||||
|
||||
// parse, clean up
|
||||
try
|
||||
{
|
||||
aelfred2.parse(source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,506 @@
|
||||
<!DOCTYPE html PUBLIC
|
||||
'-//W3C//DTD XHTML 1.0 Transitional//EN'
|
||||
'http://www.w3.org/TR/xhtml1/DTD/transitional.dtd'>
|
||||
|
||||
<html><head>
|
||||
<title>package overview</title>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 1999,2000,2001 The Free Software Foundation, Inc.
|
||||
*/
|
||||
-->
|
||||
</head><body>
|
||||
|
||||
<p> This package contains Ælfred2, which includes an
|
||||
enhanced SAX2-compatible version of the Ælfred
|
||||
non-validating XML parser, a modular (and hence optional)
|
||||
DTD validating parser, and modular (and hence optional)
|
||||
JAXP glue to those.
|
||||
Use these like any other SAX2 parsers. </p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#about">About Ælfred</a><ul>
|
||||
<li><a href="#principles">Design Principles</a></li>
|
||||
<li><a href="#name">About the Name Ælfred</a></li>
|
||||
<li><a href="#encodings">Character Encodings</a></li>
|
||||
<li><a href="#violations">Known Conformance Violations</a></li>
|
||||
<li><a href="#copyright">Licensing</a></li>
|
||||
</ul></li>
|
||||
|
||||
<li><a href="#changes">Changes Since the Last Microstar Release</a><ul>
|
||||
<li><a href="#sax2">SAX2 Support</a></li>
|
||||
<li><a href="#validation">Validation</a></li>
|
||||
<li><a href="#smaller">You Want Smaller?</a></li>
|
||||
<li><a href="#bugfixes">Bugs Fixed</a></li>
|
||||
</ul></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h2><a name="about">About Ælfred</a></h2>
|
||||
|
||||
<p>Ælfred is a XML parser written in the java programming language.
|
||||
|
||||
<h3><a name="principles">Design Principles</a></h3>
|
||||
|
||||
<p>In most Java applets and applications, XML should not be the central
|
||||
feature; instead, XML is the means to another end, such as loading
|
||||
configuration information, reading meta-data, or parsing transactions.</p>
|
||||
|
||||
<p> When an XML parser is only a single component of a much larger
|
||||
program, it cannot be large, slow, or resource-intensive. With Java
|
||||
applets, in particular, code size is a significant issue. The standard
|
||||
modem is still not operating at 56 Kbaud, or sometimes even with data
|
||||
compression. Assuming an uncompressed 28.8 Kbaud modem, only about
|
||||
3 KBytes can be downloaded in one second; compression often doubles
|
||||
that speed, but a V.90 modem may not provide another doubling. When
|
||||
used with embedded processors, similar size concerns apply. </p>
|
||||
|
||||
<p> Ælfred is designed for easy and efficient use over the Internet,
|
||||
based on the following principles: </p> <ol>
|
||||
|
||||
<li> Ælfred must be as small as possible, so that it doesn't add too
|
||||
much to an applet's download time. </li>
|
||||
|
||||
<li> Ælfred must use as few class files as possible, to minimize the
|
||||
number of HTTP connections necessary. (The use of JAR files has made this
|
||||
be less of a concern.) </li>
|
||||
|
||||
<li> Ælfred must be compatible with most or all Java implementations
|
||||
and platforms. (Write once, run anywhere.) </li>
|
||||
|
||||
<li> Ælfred must use as little memory as possible, so that it does
|
||||
not take away resources from the rest of your program. (It doesn't force
|
||||
you to use DOM or a similar costly data structure API.)</li>
|
||||
|
||||
<li> Ælfred must run as fast as possible, so that it does not slow down
|
||||
the rest of your program. </li>
|
||||
|
||||
<li> Ælfred must produce correct output for well-formed and valid
|
||||
documents, but need not reject every document that is not valid or
|
||||
not well-formed. (In Ælfred2, correctness was a bigger concern
|
||||
than in the original version; and a validation option is available.) </li>
|
||||
|
||||
<li> Ælfred must provide full internationalization from the first
|
||||
release. (Ælfred2 now automatically handles all encodings
|
||||
supported by the underlying JVM; previous versions handled only
|
||||
UTF-8, UTF_16, ASCII, and ISO-8859-1.)</li>
|
||||
|
||||
</ol>
|
||||
|
||||
<p>As you can see from this list, Ælfred is designed for production
|
||||
use, but neither validation nor perfect conformance was a requirement.
|
||||
Good validating parsers exist, including one in this package,
|
||||
and you should use them as appropriate. (See conformance reviews
|
||||
available at <a href="http://www.xml.com/">http://www.xml.com</a>)
|
||||
</p>
|
||||
|
||||
<p> One of the main goals of Ælfred2 was to significantly improve
|
||||
conformance, while not significantly affecting the other goals stated above.
|
||||
Since the only use of this parser is with SAX, some classes could be
|
||||
removed, and so the overall size of Ælfred was actually reduced.
|
||||
Subsequent performance work produced a notable speedup (over twenty
|
||||
percent on larger files). That is, the tradeoffs between speed, size, and
|
||||
conformance were re-targeted towards conformance and support of newer APIs
|
||||
(SAX2), with a a positive performance impact. </p>
|
||||
|
||||
<p> The role anticipated for this version of Ælfred is as a
|
||||
lightweight Free Software SAX parser that can be used in essentially every
|
||||
Java program where the handful of conformance violations (noted below)
|
||||
are acceptable.
|
||||
That certainly includes applets, and
|
||||
nowadays one must also mention embedded systems as being even more
|
||||
size-critical.
|
||||
At this writing, all parsers that are more conformant are
|
||||
significantly larger, even when counting the optional
|
||||
validation support in this version of Ælfred. </p>
|
||||
|
||||
|
||||
<h3><a name="name">About the Name <em>Ælfred</em></a></h3>
|
||||
|
||||
<p>Ælfred the Great (AElfred in ASCII) was King of Wessex, and
|
||||
some say of King of England, at the time of his death in 899 AD.
|
||||
Ælfred introduced a wide-spread literacy program in the hope that
|
||||
his people would learn to read English, at least, if Latin was too
|
||||
difficult for them. This Ælfred hopes to bring another sort of
|
||||
literacy to Java, using XML, at least, if full SGML is too difficult.</p>
|
||||
|
||||
<p>The initial Æ ligature ("AE)" is also a reminder that XML is
|
||||
not limited to ASCII.</p>
|
||||
|
||||
|
||||
<h3><a name="encodings">Character Encodings</a></h3>
|
||||
|
||||
<p> The Ælfred parser currently builds in support for a handful
|
||||
of input encodings. Of course these include UTF-8 and UTF-16, which
|
||||
all XML parsers are required to support:</p> <ul>
|
||||
|
||||
<li> UTF-8 ... the standard eight bit encoding, used unless
|
||||
you provide an encoding declaration or a MIME charset tag.</li>
|
||||
|
||||
<li> US-ASCII ... an extremely common seven bit encoding,
|
||||
which happens to be a subset of UTF-8 and ISO-8859-1 as well
|
||||
as many other encodings. XHTML web pages using US-ASCII
|
||||
(without an encoding declaration) are probably more
|
||||
widely interoperable than those in any other encoding. </li>
|
||||
|
||||
<li> ISO-8859-1 ... includes accented characters used in
|
||||
much of western Europe (but excluding the Euro currency
|
||||
symbol).</li>
|
||||
|
||||
<li> UTF-16 ... with several variants, this encodes each
|
||||
sixteen bit Unicode character in sixteen bits of output.
|
||||
Variants include UTF-16BE (big endian, no byte order mark),
|
||||
UTF-16LE (little endian, no byte order mark), and
|
||||
ISO-10646-UCS-2 (an older and less used encoding, using a
|
||||
version of Unicode without surrogate pairs). This is
|
||||
essentially the native encoding used by Java. </li>
|
||||
|
||||
<li> ISO-10646-UCS-4 ... a seldom-used four byte encoding,
|
||||
also known as UTF-32BE. Four byte order variants are supported,
|
||||
including one known as UTF-32LE. Some operating systems
|
||||
standardized on UCS-4 despite its significant size penalty,
|
||||
in anticipation that Unicode (even with surrogate pairs)
|
||||
would eventually become limiting. UCS-4 permits encoding
|
||||
of non-Unicode characters, which Java can't represent (and
|
||||
XML doesn't allow).
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p> If you use any encoding other than UTF-8 or UTF-16 you should
|
||||
make sure to label your data appropriately: </p>
|
||||
|
||||
<blockquote>
|
||||
<?xml version="1.0" encoding="<b>ISO-8859-15</b>"?>
|
||||
</blockquote>
|
||||
|
||||
<p> Encodings accessed through <code>java.io.InputStreamReader</code>
|
||||
are now fully supported for both external labels (such as MIME types)
|
||||
and internal types (as shown above).
|
||||
There is one limitation in the support for internal labels:
|
||||
the encodings must be derived from the US-ASCII encoding,
|
||||
the EBCDIC family of encodings is not recognized.
|
||||
Note that Java defines its
|
||||
own encoding names, which don't always correspond to the standard
|
||||
Internet encoding names defined by the IETF/IANA, and that Java
|
||||
may even <em>require</em> use of nonstandard encoding names.
|
||||
Please report
|
||||
such problems; some of them can be worked around in this parser,
|
||||
and many can be worked around by using external labels.
|
||||
</p>
|
||||
|
||||
<p>Note that if you are using the Euro symbol with an fixed length
|
||||
eight bit encoding, you should probably be using the encoding label
|
||||
<em>iso-8859-15</em> or, with a Microsoft OS, <em>cp-1252</em>.
|
||||
Of course, UTF-8 and UTF-16 handle the Euro symbol directly.
|
||||
</p>
|
||||
|
||||
|
||||
<h3><a name="violations">Known Conformance Violations</a></h3>
|
||||
|
||||
<p>Known conformance issues should be of negligible importance for
|
||||
most applications, and include: </p><ul>
|
||||
|
||||
<li> Rather than following the voluminous "Appendix B" rules about
|
||||
what characters may appear in names (and name tokens), the Unicode
|
||||
rules embedded in <em>java.lang.Character</em> are used.
|
||||
This means mostly that some names are inappropriately accepted,
|
||||
though a few are inappropriately rejected. (It's much simpler
|
||||
to avoid that much special case code. Recent OASIS/NIST test
|
||||
cases may have these rules be realistically testable.) </li>
|
||||
|
||||
<li> Text containing "]]>" is not rejected unless it fully resides
|
||||
in an internal buffer ... which is, thankfully, the typical case. This
|
||||
text is illegal, but sometimes appears in illegal attempts to
|
||||
nest CDATA sections. (Not catching that boundary condition
|
||||
substantially simplifies parsing text.) </li>
|
||||
|
||||
<li> Surrogate characters that aren't correctly paired are ignored
|
||||
rather than rejected, unless they were encoded using UTF-8. (This
|
||||
simplifies parsing text.) Unicode 3.1 assigned the first characters
|
||||
to those character codes, in early 2001, so few documents (or tools)
|
||||
use such characters in any case. </li>
|
||||
|
||||
<li> Declarations following references to an undefined parameter
|
||||
entity reference are not ignored. (Not maintaining and using state
|
||||
about this validity error simplifies declaration handling; few
|
||||
XML parsers address this constraint in any case.) </li>
|
||||
|
||||
<li> Well formedness constraints for general entity references
|
||||
are not enforced. (The code to handle the "content" production
|
||||
is merged with the element parsing code, making it hard to reuse
|
||||
for this additional situation.) </li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p> When tested against the July 12, 1999 version of the OASIS
|
||||
XML Conformance test suite, an earlier version passed 1057 of 1067 tests.
|
||||
That contrasts with the original version, which passed 867. The
|
||||
current parser is top-ranked in terms of conformance, as is its
|
||||
validating sibling (which has some additional conformance violations
|
||||
imposed on it by SAX2 API deficiencies as well as some of the more
|
||||
curious SGML layering artifacts found in the XML specification). </p>
|
||||
|
||||
<p> The XML 1.0 specification itself was not without problems,
|
||||
and after some delays the W3C has come out with a revised
|
||||
"second edition" specification. While that doesn't resolve all
|
||||
the problems identified the XML specification, many of the most
|
||||
egregious problems have been resolved. (You still need to drink
|
||||
magic Kool-Aid before some DTD-related issues make sense.)
|
||||
To the extent possible, this parser conforms to that second
|
||||
edition specification, and does well against corrected versions
|
||||
of the OASIS/NIST XML conformance test cases. See <a href=
|
||||
"http://xmlconf.sourceforge.net">http://xmlconf.sourceforge.net</a>
|
||||
for more information about SAX2/XML conformance testing. </p>
|
||||
|
||||
|
||||
<h3><a name="copyright">Copyright and distribution terms</a></h3>
|
||||
|
||||
<p>
|
||||
The software in this package is distributed under the GNU General Public
|
||||
License (with a special exception described below).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A copy of GNU General Public License (GPL) is included in this distribution,
|
||||
in the file COPYING. If you do not have the source code, it is available at:
|
||||
|
||||
<a href="http://www.gnu.org/software/classpath/">http://www.gnu.org/software/classpath/</a>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version.
|
||||
|
||||
Parts derived from code which carried the following notice:
|
||||
|
||||
Copyright (c) 1997, 1998 by Microstar Software Ltd.
|
||||
|
||||
AElfred is free for both commercial and non-commercial use and
|
||||
redistribution, provided that Microstar's copyright and disclaimer are
|
||||
retained intact. You are free to modify AElfred for your own use and
|
||||
to redistribute AElfred with your modifications, provided that the
|
||||
modifications are clearly documented.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
merchantability or fitness for a particular purpose. Please use it AT
|
||||
YOUR OWN RISK.
|
||||
</pre>
|
||||
|
||||
<p> Some of this documentation was modified from the original
|
||||
Ælfred README.txt file. All of it has been updated. </p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a name="changes">Changes Since the last Microstar Release</a></h2>
|
||||
|
||||
<p> As noted above, Microstar has not updated this parser since
|
||||
the summer of 1998, when it released version 1.2a on its web site.
|
||||
This release is intended to benefit the developer community by
|
||||
refocusing the API on SAX2, and improving conformance to the extent
|
||||
that most developers should not need to use another XML parser. </p>
|
||||
|
||||
<p> The code has been cleaned up (referring to the XML 1.0 spec in
|
||||
all the production numbers in
|
||||
comments, rather than some preliminary draft, for one example) and
|
||||
has been sped up a bit as well.
|
||||
JAXP support has been added, although developers are still
|
||||
strongly encouraged to use the SAX2 APIs directly. </p>
|
||||
|
||||
|
||||
<h3><a name="sax2">SAX2 Support</a></h3>
|
||||
|
||||
<p> The original version of Ælfred did not support the
|
||||
SAX2 APIs. </p>
|
||||
|
||||
<p> This version supports the SAX2 APIs, exposing the standard
|
||||
boolean feature descriptors. It supports the "DeclHandler" property
|
||||
to provide access to all DTD declarations not already exposed
|
||||
through the SAX1 API. The "LexicalHandler" property is supported,
|
||||
exposing entity boundaries (including the unnamed external subset) and
|
||||
things like comments and CDATA boundaries. SAX1 compatibility is
|
||||
currently provided.</p>
|
||||
|
||||
|
||||
<h3><a name="validation">Validation</a></h3>
|
||||
|
||||
<p> In the 'pipeline' package in this same software distribution is an
|
||||
<a href="../pipeline/ValidationConsumer.html">XML Validation component</a>
|
||||
using any full SAX2 event stream (including all document type declarations)
|
||||
to validate. There is now a <a href="XmlReader.html">XmlReader</a> class
|
||||
which combines that class and this enhanced Ælfred parser, creating
|
||||
an optionally validating SAX2 parser. </p>
|
||||
|
||||
<p> As noted in the documentation for that validating component, certain
|
||||
validity constraints can't reliably be tested by a layered validator.
|
||||
These include all constraints relying on
|
||||
layering violations (exposing XML at the level of tokens or below,
|
||||
required since XML isn't a context-free grammar), some that
|
||||
SAX2 doesn't support, and a few others. The resulting validating
|
||||
parser is conformant enough for most applications that aren't doing
|
||||
strange SGML tricks with DTDs.
|
||||
Moreover, that validating filter can be used without
|
||||
a parser ... any application component that emits SAX event streams
|
||||
can DTD-validate its output on demand. </p>
|
||||
|
||||
<h3><a name="smaller">You want Smaller?</a></h3>
|
||||
|
||||
<p> You'll have noticed that the original version of Ælfred
|
||||
had small size as a top goal. Ælfred2 normally includes a
|
||||
DTD validation layer, but you can package without that.
|
||||
Similarly, JAXP factory support is available but optional.
|
||||
Then the main added cost due to this revision are for
|
||||
supporting the SAX2 API itself; DTD validation is as
|
||||
cleanly layered as allowed by SAX2.</p>
|
||||
|
||||
<h3><a name="bugfixes">Bugs Fixed</a></h3>
|
||||
|
||||
<p> Bugs fixed in Ælfred2 include: </p>
|
||||
|
||||
<ol>
|
||||
<li> Originally Ælfred didn't close file descriptors, which
|
||||
led to file descriptor leakage on programs which ran for any
|
||||
length of time. </li>
|
||||
|
||||
<li> NOTATION declarations without system identifiers are
|
||||
now handled correctly. </li>
|
||||
|
||||
<li> DTD events are now reported for all invocations of a
|
||||
given parser, not just the first one. </li>
|
||||
|
||||
<li> More correct character handling: <ul>
|
||||
|
||||
<li> Rejects out-of-range characters, both in text and in
|
||||
character references. </li>
|
||||
|
||||
<li> Correctly handles character references that expand to
|
||||
surrogate pairs. </li>
|
||||
|
||||
<li> Correctly handles UTF-8 encodings of surrogate pairs. </li>
|
||||
|
||||
<li> Correctly handles Unicode 3.1 rules about illegal UTF-8
|
||||
encodings: there is only one legal encoding per character. </li>
|
||||
|
||||
<li> PUBLIC identifiers are now rejected if they have illegal
|
||||
characters. </li>
|
||||
|
||||
<li> The parser is more correct about what characters are allowed
|
||||
in names and name tokens. Uses Unicode rules (built in to Java)
|
||||
rather than the voluminous XML rules, although some extensions
|
||||
have been made to match XML rules more closely.</li>
|
||||
|
||||
<li> Line ends are now normalized to newlines in all known
|
||||
cases. </li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li> Certain validity errors were previously treated as well
|
||||
formedness violations. <ul>
|
||||
|
||||
<li> Repeated declarations of an element type are no
|
||||
longer fatal errors. </li>
|
||||
|
||||
<li> Undeclared parameter entity references are no longer
|
||||
fatal errors. </li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li> Attribute handling is improved: <ul>
|
||||
|
||||
<li> Whitespace must exist between attributes. </li>
|
||||
|
||||
<li> Only one value for a given attribute is permitted. </li>
|
||||
|
||||
<li> ATTLIST declarations don't need to declare attributes. </li>
|
||||
|
||||
<li> Attribute values are normalized when required. </li>
|
||||
|
||||
<li> Tabs in attribute values are normalized to spaces. </li>
|
||||
|
||||
<li> Attribute values containing a literal "<" are rejected. </li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li> More correct entity handling: <ul>
|
||||
|
||||
<li> Whitespace must precede NDATA when declaring unparsed
|
||||
entities.</li>
|
||||
|
||||
<li> Parameter entity declarations may not have NDATA annotations. </li>
|
||||
|
||||
<li> The XML specification has a bug in that it doesn't specify
|
||||
that certain contexts exist within which parameter entity
|
||||
expansion must not be performed. Lacking an offical erratum,
|
||||
this parser now disables such expansion inside comments,
|
||||
processing instructions, ignored sections, public identifiers,
|
||||
and parts of entity declarations. </li>
|
||||
|
||||
<li> Entity expansions that include quote characters no longer
|
||||
confuse parsing of strings using such expansions. </li>
|
||||
|
||||
<li> Whitespace in the values of internal entities is not mapped
|
||||
to space characters. </li>
|
||||
|
||||
<li> General Entity references in attribute defaults within the
|
||||
DTD now cause fatal errors when the entity is not defined at the
|
||||
time it is referenced. </li>
|
||||
|
||||
<li> Malformed general entity references in entity declarations are
|
||||
now detected. </li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li> Neither conditional sections
|
||||
nor parameter entity references within markup declarations
|
||||
are permitted in the internal subset. </li>
|
||||
|
||||
<li> Processing instructions whose target names are "XML"
|
||||
(ignoring case) are now rejected. </li>
|
||||
|
||||
<li> Comments may not include "--".</li>
|
||||
|
||||
<li> Most "]]>" sequences in text are rejected. </li>
|
||||
|
||||
<li> Correct syntax for standalone declarations is enforced. </li>
|
||||
|
||||
<li> Setting a locale for diagnostics only produces an exception
|
||||
if the language of that locale isn't English. </li>
|
||||
|
||||
<li> Some more encoding names are recognized. These include the
|
||||
Unicode 3.0 variants of UTF-16 (UTF-16BE, UTF-16LE) as well as
|
||||
US-ASCII and a few commonly seen synonyms. </li>
|
||||
|
||||
<li> Text (from character content, PIs, or comments) large enough
|
||||
not to fit into internal buffers is now handled correctly even in
|
||||
some cases which were originally handled incorrectly.</li>
|
||||
|
||||
<li> Content is now reported for element types for which attributes
|
||||
have been declared, but no content model is known. (Such documents
|
||||
are invalid, but may still be well formed.) </li>
|
||||
|
||||
</ol>
|
||||
|
||||
<p> Other bugs may also have been fixed. </p>
|
||||
|
||||
<p> For better overall validation support, some of the validity
|
||||
constraints that can't be verified using the SAX2 event stream
|
||||
are now reported directly by Ælfred2. </p>
|
||||
|
||||
</body></html>
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/* Consumer.java --
|
||||
Copyright (C) 2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.Attributes2;
|
||||
|
||||
import gnu.xml.pipeline.DomConsumer;
|
||||
import gnu.xml.pipeline.EventConsumer;
|
||||
|
||||
|
||||
/**
|
||||
* Event consumer which constructs DOM documents using the implementation
|
||||
* in this package, using SAX2 events. This packages various backdoors
|
||||
* into this DOM implementation, as needed to address DOM requirements
|
||||
* that can't be met by strictly conforming implementations of DOM.
|
||||
*
|
||||
* <p> These requirements all relate to {@link DocumentType} nodes and
|
||||
* features of that node type. These features are normally not used,
|
||||
* because that interface only exposes a subset of the information found
|
||||
* in DTDs. More, that subset does not include the most important typing
|
||||
* information. For example, it excludes element content models and
|
||||
* attribute typing. It does expose some entity management issues,
|
||||
* although entity management doesn't relate to document typing.
|
||||
*
|
||||
* <p> Note that SAX2 does not expose the literal text of the DTD's
|
||||
* internal subset, so it will not be present in DOM trees constructed
|
||||
* using this API. (Though with a good SAX2 implementation, it could
|
||||
* be partially recreated...)
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public class Consumer extends DomConsumer
|
||||
{
|
||||
/**
|
||||
* Constructs an unconfigured event consumer,
|
||||
* as a terminus in a SAX event pipeline.
|
||||
*/
|
||||
// used by PipelineFactory [terminus]
|
||||
public Consumer ()
|
||||
throws SAXException
|
||||
{
|
||||
super (DomDocument.class);
|
||||
setHandler (new Backdoor (this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an unconfigured event consumer,
|
||||
* as a stage in a SAX event pipeline.
|
||||
*/
|
||||
// used by PipelineFactory [filter]
|
||||
public Consumer (EventConsumer next)
|
||||
throws SAXException
|
||||
{
|
||||
super (DomDocument.class, next);
|
||||
setHandler (new Backdoor (this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the backdoors needed by DOM.
|
||||
* All methods in this class use implementation-specific APIs that are
|
||||
* implied by the DOM specification (needed to implement testable
|
||||
* behavior) but which are excluded from the DOM specification.
|
||||
*/
|
||||
public static class Backdoor extends DomConsumer.Handler
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
* @param consumer must have been initialized to use the
|
||||
* {@link DomDocument} class (or a subclass) for
|
||||
* constructing DOM trees
|
||||
*/
|
||||
protected Backdoor (DomConsumer consumer)
|
||||
throws SAXException
|
||||
{ super (consumer); }
|
||||
|
||||
// helper routine
|
||||
private DomDoctype getDoctype ()
|
||||
throws SAXException
|
||||
{
|
||||
DomDocument doc = (DomDocument) getDocument ();
|
||||
DocumentType dt = doc.getDoctype ();
|
||||
|
||||
if (dt == null)
|
||||
throw new SAXException ("doctype missing!");
|
||||
return (DomDoctype) dt;
|
||||
}
|
||||
|
||||
// SAX2 "lexical" event
|
||||
public void startDTD (String name, String publicId, String systemId)
|
||||
throws SAXException
|
||||
{
|
||||
DomDocument doc = (DomDocument) getDocument ();
|
||||
|
||||
super.startDTD (name, publicId, systemId);
|
||||
// DOM L2 doctype creation model is bizarre
|
||||
DomDoctype dt = new DomDoctype (doc, name, publicId, systemId);
|
||||
doc.appendChild (dt);
|
||||
}
|
||||
|
||||
// SAX2 "lexical" event
|
||||
public void endDTD ()
|
||||
throws SAXException
|
||||
{
|
||||
super.endDTD ();
|
||||
// DOM L2 has no way to make things readonly
|
||||
getDoctype ().makeReadonly ();
|
||||
}
|
||||
|
||||
// SAX1 DTD event
|
||||
public void notationDecl (
|
||||
String name,
|
||||
String publicId, String systemId
|
||||
) throws SAXException
|
||||
{
|
||||
// DOM L2 can't create/save notation nodes
|
||||
getDoctype ().declareNotation (name, publicId, systemId);
|
||||
}
|
||||
|
||||
// SAX1 DTD event
|
||||
public void unparsedEntityDecl (
|
||||
String name,
|
||||
String publicId, String systemId,
|
||||
String notationName
|
||||
) throws SAXException
|
||||
{
|
||||
// DOM L2 can't create/save entity nodes
|
||||
getDoctype ().declareEntity (name, publicId, systemId,
|
||||
notationName);
|
||||
}
|
||||
|
||||
// SAX2 declaration event
|
||||
public void internalEntityDecl (String name, String value)
|
||||
throws SAXException
|
||||
{
|
||||
// DOM L2 can't create/save entity nodes
|
||||
// NOTE: this doesn't save the value as a child of this
|
||||
// node, though it could realistically do so.
|
||||
getDoctype ().declareEntity (name, null, null, null);
|
||||
}
|
||||
|
||||
// SAX2 declaration event
|
||||
public void externalEntityDecl (
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId
|
||||
) throws SAXException
|
||||
{
|
||||
// DOM L2 can't create/save entity nodes
|
||||
// NOTE: DOM allows for these to have children, if
|
||||
// they don't have unbound namespace references.
|
||||
getDoctype ().declareEntity (name, publicId, systemId, null);
|
||||
}
|
||||
|
||||
// SAX2 element
|
||||
public void startElement (
|
||||
String uri,
|
||||
String localName,
|
||||
String qName,
|
||||
Attributes atts
|
||||
) throws SAXException
|
||||
{
|
||||
Node top;
|
||||
|
||||
super.startElement (uri, localName, qName, atts);
|
||||
|
||||
// might there be more work?
|
||||
top = getTop ();
|
||||
if (!top.hasAttributes () || !(atts instanceof Attributes2))
|
||||
return;
|
||||
|
||||
// remember any attributes that got defaulted
|
||||
DomNamedNodeMap map = (DomNamedNodeMap) top.getAttributes ();
|
||||
Attributes2 attrs = (Attributes2) atts;
|
||||
int length = atts.getLength ();
|
||||
|
||||
//map.compact ();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (attrs.isSpecified (i))
|
||||
continue;
|
||||
|
||||
// value was defaulted.
|
||||
String temp = attrs.getQName (i);
|
||||
DomAttr attr;
|
||||
|
||||
if ("".equals (temp))
|
||||
attr = (DomAttr) map.getNamedItemNS (attrs.getURI (i),
|
||||
atts.getLocalName (i));
|
||||
else
|
||||
attr = (DomAttr) map.getNamedItem (temp);
|
||||
|
||||
// DOM L2 can't write this flag, only read it
|
||||
attr.setSpecified (false);
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement (
|
||||
String uri,
|
||||
String localName,
|
||||
String qName
|
||||
) throws SAXException
|
||||
{
|
||||
DomNode top = (DomNode) getTop ();
|
||||
top.compact ();
|
||||
super.endElement (uri, localName, qName);
|
||||
}
|
||||
|
||||
protected Text createText (
|
||||
boolean isCDATA,
|
||||
char buf [],
|
||||
int off,
|
||||
int len
|
||||
) {
|
||||
DomDocument doc = (DomDocument) getDocument ();
|
||||
|
||||
if (isCDATA)
|
||||
return doc.createCDATASection (buf, off, len);
|
||||
else
|
||||
return doc.createTextNode (buf, off, len);
|
||||
}
|
||||
|
||||
public void elementDecl(String name, String model)
|
||||
throws SAXException
|
||||
{
|
||||
getDoctype().elementDecl(name, model);
|
||||
}
|
||||
|
||||
public void attributeDecl (
|
||||
String ename,
|
||||
String aname,
|
||||
String type,
|
||||
String mode,
|
||||
String value
|
||||
) throws SAXException
|
||||
{
|
||||
getDoctype().attributeDecl(ename, aname, type, mode, value);
|
||||
/*
|
||||
if (value == null && !"ID".equals (type))
|
||||
return;
|
||||
|
||||
DomDoctype.ElementInfo info;
|
||||
|
||||
info = getDoctype ().getElementInfo (ename);
|
||||
if (value != null)
|
||||
info.setAttrDefault (aname, value);
|
||||
if ("ID".equals (type))
|
||||
info.setIdAttr (aname);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// force duplicate name checking off while we're
|
||||
// using parser output (don't duplicate the work)
|
||||
public void startDocument () throws SAXException
|
||||
{
|
||||
super.startDocument ();
|
||||
|
||||
DomDocument doc = (DomDocument) getDocument ();
|
||||
doc.setStrictErrorChecking(false);
|
||||
doc.setBuilding(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by DOM Level 3 to report document parameters
|
||||
*/
|
||||
public void xmlDecl(String version,
|
||||
String encoding,
|
||||
boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
super.xmlDecl(version, encoding, standalone, inputEncoding);
|
||||
|
||||
DomDocument doc = (DomDocument) getDocument();
|
||||
doc.setXmlEncoding(encoding);
|
||||
doc.setInputEncoding(inputEncoding);
|
||||
}
|
||||
|
||||
public void endDocument ()
|
||||
throws SAXException
|
||||
{
|
||||
DomDocument doc = (DomDocument) getDocument ();
|
||||
doc.setStrictErrorChecking(true);
|
||||
doc.setBuilding(false);
|
||||
doc.compact ();
|
||||
DomDoctype doctype = (DomDoctype) doc.getDoctype();
|
||||
if (doctype != null)
|
||||
{
|
||||
doctype.makeReadonly();
|
||||
}
|
||||
super.endDocument ();
|
||||
}
|
||||
|
||||
// these three methods collaborate to populate entity
|
||||
// refs, marking contents readonly on end-of-entity
|
||||
|
||||
public boolean canPopulateEntityRefs ()
|
||||
{ return true; }
|
||||
|
||||
public void startEntity (String name)
|
||||
throws SAXException
|
||||
{
|
||||
if (name.charAt (0) == '%' || "[dtd]".equals (name))
|
||||
return;
|
||||
super.startEntity (name);
|
||||
|
||||
DomNode top = (DomNode) getTop ();
|
||||
|
||||
if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE)
|
||||
top.readonly = false;
|
||||
}
|
||||
|
||||
public void endEntity (String name)
|
||||
throws SAXException
|
||||
{
|
||||
if (name.charAt (0) == '%' || "[dtd]".equals (name))
|
||||
return;
|
||||
DomNode top = (DomNode) getTop ();
|
||||
|
||||
if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE) {
|
||||
top.compact ();
|
||||
top.makeReadonly ();
|
||||
}
|
||||
super.endEntity (name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* DTDAttributeTypeInfo.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.TypeInfo;
|
||||
|
||||
/**
|
||||
* Attribute type information supplied by a DTD attribute declaration.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DTDAttributeTypeInfo
|
||||
implements TypeInfo
|
||||
{
|
||||
|
||||
final String elementName;
|
||||
final String name;
|
||||
final String type;
|
||||
final String mode;
|
||||
final String value;
|
||||
|
||||
DTDAttributeTypeInfo(String elementName, String name, String type,
|
||||
String mode, String value)
|
||||
{
|
||||
this.elementName = elementName;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.mode = mode;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public final String getTypeName()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public final String getTypeNamespace()
|
||||
{
|
||||
return "http://www.w3.org/TR/REC-xml";
|
||||
}
|
||||
|
||||
public final boolean isDerivedFrom(String typeNamespace, String typeName,
|
||||
int derivationMethod)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/* DTDElementTypeInfo.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import org.w3c.dom.TypeInfo;
|
||||
|
||||
/**
|
||||
* Element type information provided by a DTD element declaration.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DTDElementTypeInfo
|
||||
implements TypeInfo
|
||||
{
|
||||
|
||||
final String name;
|
||||
String model;
|
||||
HashMap attributes;
|
||||
String idAttrName;
|
||||
|
||||
DTDElementTypeInfo(String name, String model)
|
||||
{
|
||||
this.name = name;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public final String getTypeName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getTypeNamespace()
|
||||
{
|
||||
return "http://www.w3.org/TR/REC-xml";
|
||||
}
|
||||
|
||||
public final boolean isDerivedFrom(String typeNamespace, String typeName,
|
||||
int derivationMethod)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DTDAttributeTypeInfo getAttributeTypeInfo(String name)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (DTDAttributeTypeInfo) attributes.get(name);
|
||||
}
|
||||
|
||||
void setAttributeTypeInfo(String name, DTDAttributeTypeInfo info)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
attributes = new HashMap();
|
||||
}
|
||||
attributes.put(name, info);
|
||||
if ("ID".equals(info.type))
|
||||
{
|
||||
idAttrName = name;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator attributes()
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return attributes.values().iterator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,380 @@
|
||||
/* DomAttr.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.TypeInfo;
|
||||
import org.w3c.dom.events.MutationEvent;
|
||||
|
||||
|
||||
/**
|
||||
* <p> "Attr" implementation. In DOM, attributes cost quite a lot of
|
||||
* memory because their values are complex structures rather than just
|
||||
* simple strings. To reduce your costs, avoid having more than one
|
||||
* child of an attribute; stick to a single Text node child, and ignore
|
||||
* even that by using the attribute's "nodeValue" property.</p>
|
||||
*
|
||||
* <p> As a bit of general advice, only look at attribute modification
|
||||
* events through the DOMAttrModified event (sent to the associated
|
||||
* element). Implementations are not guaranteed to report other events
|
||||
* in the same order, so you're very likely to write nonportable code if
|
||||
* you monitor events at the "children of Attr" level.</p>
|
||||
*
|
||||
* <p> At this writing, not all attribute modifications will cause the
|
||||
* DOMAttrModified event to be triggered ... only the ones using the string
|
||||
* methods (setNodeValue, setValue, and Element.setAttribute) to modify
|
||||
* those values. That is, if you manipulate those children directly,
|
||||
* elements won't get notified that attribute values have changed.
|
||||
* The natural fix for that will report other modifications, but won't
|
||||
* be able to expose "previous" attribute value; it'll need to be cached
|
||||
* or something (at which point why bother using child nodes). </p>
|
||||
*
|
||||
* <p><em>You are strongly advised not to use "children" of any attribute
|
||||
* nodes you work with.</em> </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomAttr
|
||||
extends DomNsNode
|
||||
implements Attr
|
||||
{
|
||||
|
||||
private boolean specified;
|
||||
private String value; // string value cache
|
||||
|
||||
/**
|
||||
* Constructs an Attr node associated with the specified document.
|
||||
* The "specified" flag is initialized to true, since this DOM has
|
||||
* no current "back door" mechanisms to manage default values so
|
||||
* that every value must effectively be "specified".
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part of
|
||||
* its createAttribute functionality, or through a subclass which is
|
||||
* similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* @param owner The document with which this node is associated
|
||||
* @param namespaceURI Combined with the local part of the name,
|
||||
* this is used to uniquely identify a type of attribute
|
||||
* @param name Name of this attribute, which may include a prefix
|
||||
*/
|
||||
protected DomAttr(DomDocument owner, String namespaceURI, String name)
|
||||
{
|
||||
super(ATTRIBUTE_NODE, owner, namespaceURI, name);
|
||||
specified = true;
|
||||
length = 1;
|
||||
|
||||
// XXX register self to get insertion/removal events
|
||||
// and character data change events and when they happen,
|
||||
// report self-mutation
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the attribute name (same as getNodeName)
|
||||
*/
|
||||
public final String getName()
|
||||
{
|
||||
return getNodeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns true if a parser reported this was in the source text.
|
||||
*/
|
||||
public final boolean getSpecified()
|
||||
{
|
||||
return specified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records whether this attribute was in the source text.
|
||||
*/
|
||||
public final void setSpecified(boolean value)
|
||||
{
|
||||
specified = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the attribute value, with character and entity
|
||||
* references substituted.
|
||||
* <em>NOTE: entity refs as children aren't currently handled.</em>
|
||||
*/
|
||||
public String getNodeValue()
|
||||
{
|
||||
// If we have a simple node-value, use that
|
||||
if (first == null)
|
||||
{
|
||||
return (value == null) ? "" : value;
|
||||
}
|
||||
// Otherwise collect child node-values
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
switch (ctx.nodeType)
|
||||
{
|
||||
case Node.TEXT_NODE:
|
||||
buf.append(ctx.getNodeValue());
|
||||
break;
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the value of the attribute; it will have one child,
|
||||
* which is a text node with the specified value (same as
|
||||
* setNodeValue).
|
||||
*/
|
||||
public final void setValue(String value)
|
||||
{
|
||||
setNodeValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the value of the attribute as a non-null string; same
|
||||
* as getNodeValue.
|
||||
* <em>NOTE: entity refs as children aren't currently handled.</em>
|
||||
*/
|
||||
public final String getValue()
|
||||
{
|
||||
return getNodeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the attribute value; using this API, no entity or
|
||||
* character references will exist.
|
||||
* Causes a DOMAttrModified mutation event to be sent.
|
||||
*/
|
||||
public void setNodeValue(String value)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
String oldValue = getNodeValue();
|
||||
while (last != null)
|
||||
{
|
||||
removeChild(last);
|
||||
}
|
||||
// don't create a new node just for this...
|
||||
/*
|
||||
Node text = owner.createTextNode(value);
|
||||
appendChild(text);
|
||||
*/
|
||||
this.value = value;
|
||||
length = 1;
|
||||
specified = true;
|
||||
|
||||
mutating(oldValue, value, MutationEvent.MODIFICATION);
|
||||
}
|
||||
|
||||
public final Node getFirstChild()
|
||||
{
|
||||
// Create a child text node if necessary
|
||||
if (first == null)
|
||||
{
|
||||
length = 0;
|
||||
Node text = owner.createTextNode((value == null) ? "" : value);
|
||||
appendChild(text);
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
public final Node getLastChild()
|
||||
{
|
||||
// Create a child text node if necessary
|
||||
if (last == null)
|
||||
{
|
||||
length = 0;
|
||||
Node text = owner.createTextNode((value == null) ? "" : value);
|
||||
appendChild(text);
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
public Node item(int index)
|
||||
{
|
||||
// Create a child text node if necessary
|
||||
if (first == null)
|
||||
{
|
||||
length = 0;
|
||||
Node text = owner.createTextNode((value == null) ? "" : value);
|
||||
appendChild(text);
|
||||
}
|
||||
return super.item(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the element with which this attribute is associated.
|
||||
*/
|
||||
public final Element getOwnerElement()
|
||||
{
|
||||
return (Element) parent;
|
||||
}
|
||||
|
||||
public final Node getNextSibling()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public final Node getPreviousSibling()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getParentNode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the element with which this attribute is associated.
|
||||
*/
|
||||
public final void setOwnerElement(Element e)
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
if (!(e instanceof DomElement))
|
||||
{
|
||||
throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
|
||||
}
|
||||
parent = (DomElement) e;
|
||||
depth = parent.depth + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI of an Attr is always <code>null</code>.
|
||||
*/
|
||||
public final String getBaseURI()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shallow clone of the attribute, breaking all ties with any
|
||||
* elements.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
DomAttr retval = (DomAttr) super.clone();
|
||||
retval.specified = true;
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void mutating(String oldValue, String newValue, short why)
|
||||
{
|
||||
if (!reportMutations || parent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// EVENT: DOMAttrModified, target = parent,
|
||||
// prev/new values provided, also attr name
|
||||
MutationEvent event;
|
||||
|
||||
event = (MutationEvent) createEvent ("MutationEvents");
|
||||
event.initMutationEvent ("DOMAttrModified",
|
||||
true /* bubbles */, false /* nocancel */,
|
||||
null, oldValue, newValue, getNodeName (), why);
|
||||
parent.dispatchEvent (event);
|
||||
}
|
||||
|
||||
// DOM Level 3 methods
|
||||
|
||||
public TypeInfo getSchemaTypeInfo()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
// DTD implementation
|
||||
DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
|
||||
if (doctype != null)
|
||||
{
|
||||
return doctype.getAttributeTypeInfo(parent.getNodeName(),
|
||||
getNodeName());
|
||||
}
|
||||
// TODO XML Schema implementation
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isId()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
|
||||
if (doctype != null)
|
||||
{
|
||||
DTDAttributeTypeInfo info =
|
||||
doctype.getAttributeTypeInfo(parent.getNodeName(),
|
||||
getNodeName());
|
||||
if (info != null && "ID".equals(info.type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DomElement element = (DomElement) parent;
|
||||
if (element.userIdAttrs != null &&
|
||||
element.userIdAttrs.contains(this))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// TODO XML Schema implementation
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/* DomCDATASection.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.CDATASection;
|
||||
|
||||
/**
|
||||
* <p> "CDATASection" implementation.
|
||||
* This is a non-core DOM class, supporting the "XML" feature.
|
||||
* CDATA sections are just ways to represent text using different
|
||||
* delimeters. </p>
|
||||
*
|
||||
* <p> <em>You are strongly advised not to use CDATASection nodes.</em>
|
||||
* The advantage of having slightly prettier ways to print text that may
|
||||
* have lots of embedded XML delimiters, such as "&" and "<",
|
||||
* can be dwarfed by the cost of dealing with multiple kinds of text
|
||||
* nodes in all your algorithms. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomCDATASection
|
||||
extends DomText
|
||||
implements CDATASection
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a CDATA section node associated with the specified
|
||||
* document and holding the specified data.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part of
|
||||
* its createCDATASection functionality, or through a subclass which is
|
||||
* similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
*/
|
||||
protected DomCDATASection(DomDocument owner, String value)
|
||||
{
|
||||
super(CDATA_SECTION_NODE, owner, value);
|
||||
}
|
||||
|
||||
protected DomCDATASection(DomDocument owner, char buf [], int off, int len)
|
||||
{
|
||||
super(CDATA_SECTION_NODE, owner, buf, off, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the string "#cdata-section".
|
||||
*/
|
||||
final public String getNodeName()
|
||||
{
|
||||
return "#cdata-section";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
/* DomCharacterData.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.CharacterData;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.events.MutationEvent;
|
||||
|
||||
|
||||
/**
|
||||
* <p> Abstract "CharacterData" implementation. This
|
||||
* facilitates reusing code in classes implementing subtypes of that DOM
|
||||
* interface (Text, Comment, CDATASection). </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class DomCharacterData
|
||||
extends DomNode
|
||||
implements CharacterData
|
||||
{
|
||||
|
||||
private String text;
|
||||
|
||||
// package private
|
||||
DomCharacterData(short nodeType, DomDocument doc, String value)
|
||||
{
|
||||
super(nodeType, doc);
|
||||
text = (value == null) ? "" : value;
|
||||
}
|
||||
|
||||
// package private
|
||||
DomCharacterData(short nodeType, DomDocument doc,
|
||||
char[] buf, int offset, int length)
|
||||
{
|
||||
super(nodeType, doc);
|
||||
text = (buf == null) ? "" : new String(buf, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Appends the specified data to the value of this node.
|
||||
* Causes a DOMCharacterDataModified mutation event to be reported.
|
||||
*/
|
||||
public void appendData(String arg)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
String value = text + arg;
|
||||
mutating(value);
|
||||
text = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Modifies the value of this node.
|
||||
* Causes a DOMCharacterDataModified mutation event to be reported.
|
||||
*/
|
||||
public void deleteData(int offset, int count)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
char[] raw = text.toCharArray();
|
||||
if (offset < 0 || count < 0 || offset > raw.length)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
if ((offset + count) > raw.length)
|
||||
{
|
||||
count = raw.length - offset;
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
char[] buf = new char[raw.length - count];
|
||||
System.arraycopy(raw, 0, buf, 0, offset);
|
||||
System.arraycopy(raw, offset + count, buf, offset,
|
||||
raw.length - (offset + count));
|
||||
String value = new String(buf);
|
||||
mutating(value);
|
||||
text = value;
|
||||
}
|
||||
catch (IndexOutOfBoundsException x)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the value of this node.
|
||||
*/
|
||||
public String getNodeValue()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the value of this node; same as getNodeValue.
|
||||
*/
|
||||
public final String getData()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the length of the data.
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return text.length();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Modifies the value of this node.
|
||||
*/
|
||||
public void insertData(int offset, String arg)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
char[] raw = text.toCharArray();
|
||||
char[] tmp = arg.toCharArray ();
|
||||
char[] buf = new char[raw.length + tmp.length];
|
||||
|
||||
try
|
||||
{
|
||||
System.arraycopy(raw, 0, buf, 0, offset);
|
||||
System.arraycopy(tmp, 0, buf, offset, tmp.length);
|
||||
System.arraycopy(raw, offset, buf, offset + tmp.length,
|
||||
raw.length - offset);
|
||||
String value = new String(buf);
|
||||
mutating(value);
|
||||
text = value;
|
||||
}
|
||||
catch (IndexOutOfBoundsException x)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Modifies the value of this node. Causes DOMCharacterDataModified
|
||||
* mutation events to be reported (at least one).
|
||||
*/
|
||||
public void replaceData(int offset, int count, String arg)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
char[] raw = text.toCharArray();
|
||||
|
||||
// deleteData
|
||||
if (offset < 0 || count < 0 || offset > raw.length)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
if ((offset + count) > raw.length)
|
||||
{
|
||||
count = raw.length - offset;
|
||||
}
|
||||
try
|
||||
{
|
||||
char[] buf = new char[raw.length - count];
|
||||
System.arraycopy(raw, 0, buf, 0, offset);
|
||||
System.arraycopy(raw, offset + count, buf, offset,
|
||||
raw.length - (offset + count));
|
||||
|
||||
// insertData
|
||||
char[] tmp = arg.toCharArray ();
|
||||
char[] buf2 = new char[buf.length + tmp.length];
|
||||
System.arraycopy(raw, 0, buf, 0, offset);
|
||||
System.arraycopy(tmp, 0, buf, offset, tmp.length);
|
||||
System.arraycopy(raw, offset, buf, offset + tmp.length,
|
||||
raw.length - offset);
|
||||
String value = new String(buf);
|
||||
mutating(value);
|
||||
text = value;
|
||||
}
|
||||
catch (IndexOutOfBoundsException x)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the value of this node.
|
||||
* Causes a DOMCharacterDataModified mutation event to be reported.
|
||||
*/
|
||||
public void setNodeValue(String value)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
mutating(value);
|
||||
text = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the value of this node; same as setNodeValue.
|
||||
*/
|
||||
final public void setData(String data)
|
||||
{
|
||||
setNodeValue(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the specified substring.
|
||||
*/
|
||||
public String substringData(int offset, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
return text.substring(offset, count);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (offset >= 0 && count >= 0 && offset < text.length())
|
||||
{
|
||||
return text.substring(offset);
|
||||
}
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI for character data is <code>null</code>.
|
||||
* @since DOM Level 3 Core
|
||||
*/
|
||||
public final String getBaseURI()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void mutating(String newValue)
|
||||
{
|
||||
if (!reportMutations)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// EVENT: DOMCharacterDataModified, target = this,
|
||||
// prev/new values provided
|
||||
MutationEvent event;
|
||||
|
||||
event = (MutationEvent) createEvent("MutationEvents");
|
||||
event.initMutationEvent("DOMCharacterDataModified",
|
||||
true /* bubbles */, false /* nocancel */,
|
||||
null, text, newValue, null, (short) 0);
|
||||
dispatchEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/* DomComment.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Comment;
|
||||
|
||||
/**
|
||||
* <p> "Comment" implementation.
|
||||
* Comments hold data intended for direct consumption by people;
|
||||
* programs should only use ProcessingInstruction nodes. Note that
|
||||
* since SAX makes comment reporting optional, XML systems that
|
||||
* rely on comments (such as by using this class) will often lose
|
||||
* those comments at some point in the processing pipeline. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomComment
|
||||
extends DomCharacterData
|
||||
implements Comment
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a comment node associated with the specified
|
||||
* document and holding the specified data.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part of
|
||||
* its createComment functionality, or through a subclass which is
|
||||
* similarly used in a "Sub-DOM" style layer.
|
||||
*/
|
||||
protected DomComment(DomDocument owner, String value)
|
||||
{
|
||||
super(COMMENT_NODE, owner, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the string "#comment".
|
||||
*/
|
||||
final public String getNodeName()
|
||||
{
|
||||
return "#comment";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/* DomDOMException.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* <p> DOMException implementation. The version that
|
||||
* is provided by the W3C is abstract, so it can't be instantiated.
|
||||
*
|
||||
* <p> This also provides a bit more information about the error
|
||||
* that is being reported, in terms of the relevant DOM structures
|
||||
* and data.
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public class DomDOMException
|
||||
extends DOMException
|
||||
{
|
||||
|
||||
/** @serial Data that caused an error to be reported */
|
||||
private String data;
|
||||
|
||||
/** @serial Node associated with the error. */
|
||||
private Node node;
|
||||
|
||||
/** @serial Data associated with the error. */
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Constructs an exception, with the diagnostic message
|
||||
* corresponding to the specified code.
|
||||
*/
|
||||
public DomDOMException(short code)
|
||||
{
|
||||
super(code, diagnostic(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an exception, with the diagnostic message
|
||||
* corresponding to the specified code and additional
|
||||
* information as provided.
|
||||
*/
|
||||
public DomDOMException(short code, String data, Node node, int value)
|
||||
{
|
||||
super(code, diagnostic(code));
|
||||
this.data = data;
|
||||
this.node = node;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/** Returns the node to which the diagnotic applies, or null. */
|
||||
final public Node getNode()
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
/** Returns data to which the diagnotic applies, or null. */
|
||||
final public String getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Returns data to which the diagnotic applies, or null. */
|
||||
final public int getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a diagnostic message that may be slightly more useful
|
||||
* than the generic one, where possible.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
String retval = super.getMessage();
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
retval += "\nMore Information: " + data;
|
||||
}
|
||||
if (value != 0)
|
||||
{
|
||||
retval += "\nNumber: " + value;
|
||||
}
|
||||
if (node != null)
|
||||
{
|
||||
retval += "\nNode Name: " + node.getNodeName();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
// these strings should be localizable.
|
||||
|
||||
private static String diagnostic(short code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
// DOM L1:
|
||||
case INDEX_SIZE_ERR:
|
||||
return "An index or size is out of range.";
|
||||
case DOMSTRING_SIZE_ERR:
|
||||
return "A string is too big.";
|
||||
case HIERARCHY_REQUEST_ERR:
|
||||
return "The node doesn't belong here.";
|
||||
case WRONG_DOCUMENT_ERR:
|
||||
return "The node belongs in another document.";
|
||||
case INVALID_CHARACTER_ERR:
|
||||
return "That character is not permitted.";
|
||||
case NO_DATA_ALLOWED_ERR:
|
||||
return "This node does not permit data.";
|
||||
case NO_MODIFICATION_ALLOWED_ERR:
|
||||
return "No changes are allowed.";
|
||||
case NOT_FOUND_ERR:
|
||||
return "The node was not found in that context.";
|
||||
case NOT_SUPPORTED_ERR:
|
||||
return "That object is not supported.";
|
||||
case INUSE_ATTRIBUTE_ERR:
|
||||
return "The attribute belongs to a different element.";
|
||||
|
||||
// DOM L2:
|
||||
case INVALID_STATE_ERR:
|
||||
return "The object is not usable.";
|
||||
case SYNTAX_ERR:
|
||||
return "An illegal string was provided.";
|
||||
case INVALID_MODIFICATION_ERR:
|
||||
return "An object's type may not be changed.";
|
||||
case NAMESPACE_ERR:
|
||||
return "The operation violates XML Namespaces.";
|
||||
case INVALID_ACCESS_ERR:
|
||||
return "Parameter or operation isn't supported by this node.";
|
||||
case TYPE_MISMATCH_ERR:
|
||||
return "The type of the argument is incompatible with the expected type.";
|
||||
}
|
||||
return "Reserved exception number: " + code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
/* DomDoctype.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Entity;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Notation;
|
||||
|
||||
/**
|
||||
* <p> "DocumentType" implementation (with no extensions for supporting
|
||||
* any document typing information). This is a non-core DOM class,
|
||||
* supporting the "XML" feature. </p>
|
||||
*
|
||||
* <p> <em>Few XML applications will actually care about this partial
|
||||
* DTD support</em>, since it doesn't expose any (!) of the data typing
|
||||
* facilities which can motivate applications to use DTDs. It does not
|
||||
* expose element content models, or information about attribute typing
|
||||
* rules. Plus the information it exposes isn't very useful; as one example,
|
||||
* DOM exposes information about unparsed ENTITY objects, which is only used
|
||||
* with certain element attributes, but does not expose the information about
|
||||
* those attributes which is needed to apply that data! </p>
|
||||
*
|
||||
* <p> Also, note that there are no nonportable ways to associate even the
|
||||
* notation and entity information exposed by DOM with a DocumentType. While
|
||||
* there is a DOM L2 method to construct a DocumentType, it only gives access
|
||||
* to the textual content of the <!DOCTYPE ...> declaration. </p>
|
||||
*
|
||||
* <p> In short, <em>you are strongly advised not to rely on this incomplete
|
||||
* DTD functionality</em> in your application code.</p>
|
||||
*
|
||||
* @see DomEntity
|
||||
* @see DomEntityReference
|
||||
* @see DomNotation
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomDoctype
|
||||
extends DomExtern
|
||||
implements DocumentType
|
||||
{
|
||||
|
||||
private DomNamedNodeMap notations;
|
||||
private DomNamedNodeMap entities;
|
||||
private final DOMImplementation implementation;
|
||||
private String subset;
|
||||
|
||||
private HashMap elements = new HashMap();
|
||||
private boolean ids;
|
||||
|
||||
/**
|
||||
* Constructs a DocumentType node associated with the specified
|
||||
* implementation, with the specified name.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a DOMImplementation as
|
||||
* part of its createDocumentType functionality, or through a subclass
|
||||
* which is similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* <p> Note that at this time there is no standard SAX API granting
|
||||
* access to the internal subset text, so that relying on that value
|
||||
* is not currently portable.
|
||||
*
|
||||
* @param impl The implementation with which this object is associated
|
||||
* @param name Name of this root element
|
||||
* @param publicId If non-null, provides the external subset's
|
||||
* PUBLIC identifier
|
||||
* @param systemId If non-null, provides the external subset's
|
||||
* SYSTEM identifier
|
||||
* @param internalSubset Provides the literal value (unparsed, no
|
||||
* entities expanded) of the DTD's internal subset.
|
||||
*/
|
||||
protected DomDoctype(DOMImplementation impl,
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId,
|
||||
String internalSubset)
|
||||
{
|
||||
super(DOCUMENT_TYPE_NODE, null, name, publicId, systemId);
|
||||
implementation = impl;
|
||||
subset = internalSubset;
|
||||
}
|
||||
|
||||
/**
|
||||
* JAXP builder constructor.
|
||||
* @param doc the document
|
||||
* @param name the name of the document element
|
||||
* @param publicId the public ID of the document type declaration
|
||||
* @param systemId the system ID of the document type declaration
|
||||
*/
|
||||
public DomDoctype(DomDocument doc,
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId)
|
||||
{
|
||||
super(DOCUMENT_TYPE_NODE, doc, name, publicId, systemId);
|
||||
implementation = doc.getImplementation();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the root element's name (just like getNodeName).
|
||||
*/
|
||||
final public String getName()
|
||||
{
|
||||
return getNodeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns information about any general entities declared
|
||||
* in the DTD.
|
||||
*
|
||||
* <p><em>Note: DOM L1 doesn't throw a DOMException here, but
|
||||
* then it doesn't have the strange construction rules of L2.</em>
|
||||
*
|
||||
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
|
||||
* is not associated with a document.
|
||||
*/
|
||||
public NamedNodeMap getEntities()
|
||||
{
|
||||
if (entities == null)
|
||||
{
|
||||
entities = new DomNamedNodeMap(this, Node.ENTITY_NODE);
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the declaration of a general entity in this DocumentType.
|
||||
*
|
||||
* @param name Name of the entity
|
||||
* @param publicId If non-null, provides the entity's PUBLIC identifier
|
||||
* @param systemId Provides the entity's SYSTEM identifier
|
||||
* @param notation If non-null, provides the entity's notation
|
||||
* (indicating an unparsed entity)
|
||||
* @return The Entity that was declared, or null if the entity wasn't
|
||||
* recorded (because it's a parameter entity or because an entity with
|
||||
* this name was already declared).
|
||||
*
|
||||
* @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
|
||||
* DocumentType is no longer writable.
|
||||
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
|
||||
* is not associated with a document.
|
||||
*/
|
||||
public Entity declareEntity(String name,
|
||||
String publicId,
|
||||
String systemId,
|
||||
String notation)
|
||||
{
|
||||
DomEntity entity;
|
||||
|
||||
if (name.charAt(0) == '%' || "[dtd]".equals(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
getEntities();
|
||||
|
||||
DomDocument.checkName(name, (owner != null) ?
|
||||
"1.1".equals(owner.getXmlVersion()) : false);
|
||||
if (entities.getNamedItem(name) != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
entity = new DomEntity(owner, name, publicId, systemId, notation);
|
||||
entities.setNamedItem(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns information about any notations declared in the DTD.
|
||||
*
|
||||
* <p><em>Note: DOM L1 doesn't throw a DOMException here, but
|
||||
* then it doesn't have the strange construction rules of L2.</em>
|
||||
*
|
||||
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
|
||||
* is not associated with a document.
|
||||
*/
|
||||
public NamedNodeMap getNotations()
|
||||
{
|
||||
if (notations == null)
|
||||
{
|
||||
notations = new DomNamedNodeMap(this, Node.NOTATION_NODE);
|
||||
}
|
||||
return notations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the declaration of a notation in this DocumentType.
|
||||
*
|
||||
* @param name Name of the notation
|
||||
* @param publicId If non-null, provides the notation's PUBLIC identifier
|
||||
* @param systemId If non-null, provides the notation's SYSTEM identifier
|
||||
* @return The notation that was declared.
|
||||
*
|
||||
* @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
|
||||
* DocumentType is no longer writable.
|
||||
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
|
||||
* is not associated with a document.
|
||||
*/
|
||||
public Notation declareNotation(String name,
|
||||
String publicId,
|
||||
String systemId)
|
||||
{
|
||||
DomNotation notation;
|
||||
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
getNotations();
|
||||
|
||||
DomDocument.checkName(name, (owner != null) ?
|
||||
"1.1".equals(owner.getXmlVersion()) : false);
|
||||
|
||||
notation = new DomNotation(owner, name, publicId, systemId);
|
||||
notations.setNamedItem(notation);
|
||||
return notation;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the internal subset of the document, as a string of unparsed
|
||||
* XML declarations (and comments, PIs, whitespace); or returns null if
|
||||
* there is no such subset. There is no vendor-independent expectation
|
||||
* that this attribute be set, or that declarations found in it be
|
||||
* reflected in the <em>entities</em> or <em>notations</em> attributes
|
||||
* of this Document "Type" object.
|
||||
*
|
||||
* <p> Some application-specific XML profiles require that documents
|
||||
* only use specific PUBLIC identifiers, without an internal subset
|
||||
* to modify the interperetation of the declarations associated with
|
||||
* that PUBLIC identifier through some standard.
|
||||
*/
|
||||
public String getInternalSubset()
|
||||
{
|
||||
return subset;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI of a DocumentType is always <code>null</code>.
|
||||
* See the Infoset Mapping, appendix C.
|
||||
*/
|
||||
public final String getBaseURI()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal "readonly" flag so the node and its associated
|
||||
* data (only lists of entities and notations, no type information
|
||||
* at the moment) can't be changed.
|
||||
*/
|
||||
public void makeReadonly()
|
||||
{
|
||||
super.makeReadonly();
|
||||
if (entities != null)
|
||||
{
|
||||
entities.makeReadonly();
|
||||
}
|
||||
if (notations != null)
|
||||
{
|
||||
notations.makeReadonly();
|
||||
}
|
||||
}
|
||||
|
||||
void setOwner(DomDocument doc)
|
||||
{
|
||||
if (entities != null)
|
||||
{
|
||||
for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
ctx.setOwner(doc);
|
||||
}
|
||||
}
|
||||
if (notations != null)
|
||||
{
|
||||
for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
ctx.setOwner(doc);
|
||||
}
|
||||
}
|
||||
super.setOwner(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Consults the DOM implementation to determine if the requested
|
||||
* feature is supported.
|
||||
*/
|
||||
final public boolean supports(String feature, String version)
|
||||
{
|
||||
return implementation.hasFeature(feature, version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the implementation associated with this document type.
|
||||
*/
|
||||
final public DOMImplementation getImplementation()
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
public void elementDecl(String name, String model)
|
||||
{
|
||||
DTDElementTypeInfo info = getElementTypeInfo(name);
|
||||
if (info == null)
|
||||
{
|
||||
info = new DTDElementTypeInfo(name, model);
|
||||
elements.put(name, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
DTDElementTypeInfo getElementTypeInfo(String name)
|
||||
{
|
||||
return (DTDElementTypeInfo) elements.get(name);
|
||||
}
|
||||
|
||||
public void attributeDecl(String eName, String aName, String type,
|
||||
String mode, String value)
|
||||
{
|
||||
DTDAttributeTypeInfo info = new DTDAttributeTypeInfo(eName, aName, type,
|
||||
mode, value);
|
||||
DTDElementTypeInfo elementInfo = getElementTypeInfo(eName);
|
||||
if (elementInfo == null)
|
||||
{
|
||||
elementInfo = new DTDElementTypeInfo(eName, null);
|
||||
elements.put(eName, elementInfo);
|
||||
}
|
||||
elementInfo.setAttributeTypeInfo(aName, info);
|
||||
if ("ID".equals(type))
|
||||
{
|
||||
ids = true;
|
||||
}
|
||||
}
|
||||
|
||||
DTDAttributeTypeInfo getAttributeTypeInfo(String elementName, String name)
|
||||
{
|
||||
DTDElementTypeInfo elementInfo =
|
||||
(DTDElementTypeInfo) elements.get(elementName);
|
||||
return (elementInfo == null) ? null :
|
||||
elementInfo.getAttributeTypeInfo(name);
|
||||
}
|
||||
|
||||
boolean hasIds()
|
||||
{
|
||||
return ids;
|
||||
}
|
||||
|
||||
public boolean isSameNode(Node arg)
|
||||
{
|
||||
if (equals(arg))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(arg instanceof DocumentType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DocumentType doctype = (DocumentType) arg;
|
||||
if (!equal(getPublicId(), doctype.getPublicId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!equal(getSystemId(), doctype.getSystemId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!equal(getInternalSubset(), doctype.getInternalSubset()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// TODO entities
|
||||
// TODO notations
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shallow clone of the doctype, except that associated
|
||||
* entities and notations are (deep) cloned.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
DomDoctype node = (DomDoctype) super.clone();
|
||||
|
||||
if (entities != null)
|
||||
{
|
||||
node.entities = new DomNamedNodeMap(node, Node.ENTITY_NODE);
|
||||
for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
node.entities.setNamedItem(ctx.cloneNode(true));
|
||||
}
|
||||
}
|
||||
if (notations != null)
|
||||
{
|
||||
node.notations = new DomNamedNodeMap(node, Node.NOTATION_NODE);
|
||||
for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
node.notations.setNamedItem(ctx.cloneNode(true));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,171 @@
|
||||
/* DomDocumentBuilder.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSInput;
|
||||
import org.w3c.dom.ls.LSParser;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Document builder using the GNU DOM Load & Save implementation.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomDocumentBuilder
|
||||
extends DocumentBuilder
|
||||
{
|
||||
|
||||
final DOMImplementation impl;
|
||||
final DOMImplementationLS ls;
|
||||
final LSParser parser;
|
||||
|
||||
DomDocumentBuilder(DOMImplementation impl,
|
||||
DOMImplementationLS ls,
|
||||
LSParser parser)
|
||||
{
|
||||
this.impl = impl;
|
||||
this.ls = ls;
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
public boolean isNamespaceAware()
|
||||
{
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
return ((Boolean) config.getParameter("namespaces")).booleanValue();
|
||||
}
|
||||
|
||||
public boolean isValidating()
|
||||
{
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
return ((Boolean) config.getParameter("validating")).booleanValue();
|
||||
}
|
||||
|
||||
public boolean isXIncludeAware()
|
||||
{
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
return ((Boolean) config.getParameter("xinclude-aware")).booleanValue();
|
||||
}
|
||||
|
||||
public void setEntityResolver(EntityResolver resolver)
|
||||
{
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
config.setParameter("entity-resolver", resolver);
|
||||
}
|
||||
|
||||
public void setErrorHandler(ErrorHandler handler)
|
||||
{
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
config.setParameter("error-handler", handler);
|
||||
}
|
||||
|
||||
public DOMImplementation getDOMImplementation()
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
public Document newDocument()
|
||||
{
|
||||
return impl.createDocument(null, null, null);
|
||||
}
|
||||
|
||||
public Document parse(InputStream in)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
LSInput input = ls.createLSInput();
|
||||
input.setByteStream(in);
|
||||
return parser.parse(input);
|
||||
}
|
||||
|
||||
public Document parse(InputStream in, String systemId)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
LSInput input = ls.createLSInput();
|
||||
input.setByteStream(in);
|
||||
input.setSystemId(systemId);
|
||||
return parser.parse(input);
|
||||
}
|
||||
|
||||
public Document parse(String systemId)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
return parser.parseURI(systemId);
|
||||
}
|
||||
|
||||
public Document parse(InputSource is)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
LSInput input = ls.createLSInput();
|
||||
String systemId = is.getSystemId();
|
||||
InputStream in = is.getByteStream();
|
||||
if (in != null)
|
||||
{
|
||||
input.setByteStream(in);
|
||||
}
|
||||
else
|
||||
{
|
||||
Reader reader = is.getCharacterStream();
|
||||
if (reader != null)
|
||||
{
|
||||
input.setCharacterStream(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
URL url = new URL(systemId);
|
||||
input.setByteStream(url.openStream());
|
||||
}
|
||||
}
|
||||
input.setPublicId(is.getPublicId());
|
||||
input.setSystemId(systemId);
|
||||
input.setEncoding(is.getEncoding());
|
||||
return parser.parse(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/* DomDocumentBuilderFactory.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSParser;
|
||||
|
||||
/**
|
||||
* Document builder factory that uses a DOM Level 3 Load & Save
|
||||
* implementation.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomDocumentBuilderFactory
|
||||
extends DocumentBuilderFactory
|
||||
{
|
||||
|
||||
final DOMImplementation impl;
|
||||
final DOMImplementationLS ls;
|
||||
|
||||
public DomDocumentBuilderFactory()
|
||||
{
|
||||
try
|
||||
{
|
||||
DOMImplementationRegistry reg =
|
||||
DOMImplementationRegistry.newInstance();
|
||||
impl = reg.getDOMImplementation("LS 3.0");
|
||||
if (impl == null)
|
||||
{
|
||||
throw new FactoryConfigurationError("no LS implementations found");
|
||||
}
|
||||
ls = (DOMImplementationLS) impl;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new FactoryConfigurationError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DocumentBuilder newDocumentBuilder()
|
||||
throws ParserConfigurationException
|
||||
{
|
||||
LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_ASYNCHRONOUS,
|
||||
"http://www.w3.org/TR/REC-xml");
|
||||
DOMConfiguration config = parser.getDomConfig();
|
||||
setParameter(config, "namespaces",
|
||||
isNamespaceAware() ? Boolean.TRUE : Boolean.FALSE);
|
||||
setParameter(config, "element-content-whitespace",
|
||||
isIgnoringElementContentWhitespace() ? Boolean.FALSE :
|
||||
Boolean.TRUE);
|
||||
setParameter(config, "comments",
|
||||
isIgnoringComments() ? Boolean.FALSE : Boolean.TRUE);
|
||||
setParameter(config, "expand-entity-references",
|
||||
isExpandEntityReferences() ? Boolean.TRUE : Boolean.FALSE);
|
||||
setParameter(config, "coalescing",
|
||||
isCoalescing() ? Boolean.TRUE : Boolean.FALSE);
|
||||
setParameter(config, "validating",
|
||||
isValidating() ? Boolean.TRUE : Boolean.FALSE);
|
||||
setParameter(config, "xinclude-aware",
|
||||
isXIncludeAware() ? Boolean.TRUE : Boolean.FALSE);
|
||||
return new DomDocumentBuilder(impl, ls, parser);
|
||||
}
|
||||
|
||||
void setParameter(DOMConfiguration config, String name, Object value)
|
||||
throws ParserConfigurationException
|
||||
{
|
||||
if (!config.canSetParameter(name, value))
|
||||
{
|
||||
throw new ParserConfigurationException(name);
|
||||
}
|
||||
config.setParameter(name, value);
|
||||
}
|
||||
|
||||
public Object getAttribute(String name)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAttribute(String name, Object value)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
/* DomDocumentConfiguration.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.DOMErrorHandler;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.DOMStringList;
|
||||
|
||||
/**
|
||||
* Document configuration, used to store normalization and other parameters.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomDocumentConfiguration
|
||||
implements DOMConfiguration, DOMStringList
|
||||
{
|
||||
|
||||
private static final List SUPPORTED_PARAMETERS =
|
||||
Arrays.asList(new String[] { "cdata-sections",
|
||||
"comments",
|
||||
"element-content-whitespace",
|
||||
"entities",
|
||||
"error-handler",
|
||||
"namespace-declarations",
|
||||
"split-cdata-sections",
|
||||
"infoset"});
|
||||
|
||||
boolean cdataSections = true;
|
||||
boolean comments = true;
|
||||
boolean elementContentWhitespace = true;
|
||||
boolean entities = true;
|
||||
DOMErrorHandler errorHandler;
|
||||
boolean namespaceDeclarations = true;
|
||||
boolean splitCdataSections = true;
|
||||
|
||||
public void setParameter(String name, Object value)
|
||||
throws DOMException
|
||||
{
|
||||
name = name.toLowerCase();
|
||||
if ("cdata-sections".equals(name))
|
||||
{
|
||||
cdataSections = "true".equals(value.toString());
|
||||
}
|
||||
else if ("comments".equals(name))
|
||||
{
|
||||
comments = "true".equals(value.toString());
|
||||
}
|
||||
else if ("element-content-whitespace".equals(name))
|
||||
{
|
||||
elementContentWhitespace = "true".equals(value.toString());
|
||||
}
|
||||
else if ("entities".equals(name))
|
||||
{
|
||||
entities = "true".equals(value.toString());
|
||||
}
|
||||
else if ("error-handler".equals(name))
|
||||
{
|
||||
try
|
||||
{
|
||||
errorHandler = (DOMErrorHandler) value;
|
||||
}
|
||||
catch (ClassCastException e)
|
||||
{
|
||||
throw new DomDOMException(DOMException.TYPE_MISMATCH_ERR,
|
||||
value.getClass().getName(), null, 0);
|
||||
}
|
||||
}
|
||||
else if ("namespace-declarations".equals(name))
|
||||
{
|
||||
namespaceDeclarations = "true".equals(value.toString());
|
||||
}
|
||||
else if ("split-cdata-sections".equals(name))
|
||||
{
|
||||
comments = "true".equals(value.toString());
|
||||
}
|
||||
else if ("infoset".equals(name))
|
||||
{
|
||||
if ("true".equals(value.toString()))
|
||||
{
|
||||
entities = false;
|
||||
cdataSections = false;
|
||||
namespaceDeclarations = true;
|
||||
elementContentWhitespace = true;
|
||||
comments = true;
|
||||
}
|
||||
}
|
||||
else if (("canonical-form".equals(name) ||
|
||||
"check-character-normalization".equals(name) ||
|
||||
"datatype-normalization".equals(name) ||
|
||||
"normalize-characters".equals(name) ||
|
||||
"validate".equals(name) ||
|
||||
"validate-if-schema".equals(name)) &&
|
||||
"false".equals(value.toString()))
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
else if (("namespaces".equals(name) ||
|
||||
"well-formed".equals(name)) &&
|
||||
"true".equals(value.toString()))
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
|
||||
name, null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getParameter(String name)
|
||||
throws DOMException
|
||||
{
|
||||
name = name.toLowerCase();
|
||||
if ("cdata-sections".equals(name))
|
||||
{
|
||||
return cdataSections ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("comments".equals(name))
|
||||
{
|
||||
return comments ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("element-content-whitespace".equals(name))
|
||||
{
|
||||
return elementContentWhitespace ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("entities".equals(name))
|
||||
{
|
||||
return entities ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("error-handler".equals(name))
|
||||
{
|
||||
return errorHandler;
|
||||
}
|
||||
else if ("namespace-declarations".equals(name))
|
||||
{
|
||||
return namespaceDeclarations ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("split-cdata-sections".equals(name))
|
||||
{
|
||||
return comments ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ("canonical-form".equals(name) ||
|
||||
"check-character-normalization".equals(name) ||
|
||||
"datatype-normalization".equals(name) ||
|
||||
"normalize-characters".equals(name) ||
|
||||
"validate".equals(name) ||
|
||||
"validate-if-schema".equals(name))
|
||||
{
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if ("namespaces".equals(name) ||
|
||||
"well-formed".equals(name))
|
||||
{
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
else if ("infoset".equals(name))
|
||||
{
|
||||
return (entities == false &&
|
||||
cdataSections == false &&
|
||||
namespaceDeclarations == true &&
|
||||
comments == true) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0);
|
||||
}
|
||||
|
||||
public boolean canSetParameter(String name, Object value)
|
||||
{
|
||||
name = name.toLowerCase();
|
||||
if ("error-handler".equals(name))
|
||||
{
|
||||
return (value == null || value instanceof DOMErrorHandler);
|
||||
}
|
||||
else if (contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ("canonical-form".equals(name) ||
|
||||
"check-character-normalization".equals(name) ||
|
||||
"datatype-normalization".equals(name) ||
|
||||
"normalize-characters".equals(name) ||
|
||||
"validate".equals(name) ||
|
||||
"validate-if-schema".equals(name))
|
||||
{
|
||||
return "false".equals(value.toString());
|
||||
}
|
||||
else if ("namespaces".equals(name) ||
|
||||
"well-formed".equals(name))
|
||||
{
|
||||
return "true".equals(value.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DOMStringList getParameterNames()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public String item(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (String) SUPPORTED_PARAMETERS.get(i);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return SUPPORTED_PARAMETERS.size();
|
||||
}
|
||||
|
||||
public boolean contains(String str)
|
||||
{
|
||||
str = str.toLowerCase();
|
||||
return SUPPORTED_PARAMETERS.contains(str);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* DomDocumentFragment.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DocumentFragment;
|
||||
|
||||
/**
|
||||
* <p> "DocumentFragment" implementation. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomDocumentFragment
|
||||
extends DomNode
|
||||
implements DocumentFragment
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a DocumentFragment node associated with the
|
||||
* specified document.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part of
|
||||
* its createDocumentFragment functionality, or through a subclass which
|
||||
* is similarly used in a "Sub-DOM" style layer.
|
||||
*/
|
||||
protected DomDocumentFragment(DomDocument owner)
|
||||
{
|
||||
super(DOCUMENT_FRAGMENT_NODE, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the string "#document-fragment".
|
||||
*/
|
||||
final public String getNodeName()
|
||||
{
|
||||
return "#document-fragment";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,523 @@
|
||||
/* DomElement.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.xml.XMLConstants;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.TypeInfo;
|
||||
|
||||
/**
|
||||
* <p> "Element" implementation.
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomElement
|
||||
extends DomNsNode
|
||||
implements Element
|
||||
{
|
||||
|
||||
/**
|
||||
* User-defined ID attributes.
|
||||
* Used by DomAttr.isId and DomDocument.getElementById
|
||||
*/
|
||||
Set userIdAttrs;
|
||||
|
||||
// Attributes are VERY expensive in DOM, and not just for
|
||||
// this implementation. Avoid creating them.
|
||||
private DomNamedNodeMap attributes;
|
||||
|
||||
// xml:space cache
|
||||
String xmlSpace = "";
|
||||
|
||||
/**
|
||||
* Constructs an Element node associated with the specified document.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part
|
||||
* of its createElement functionality, or through a subclass which is
|
||||
* similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* @param owner The document with which this node is associated
|
||||
* @param namespaceURI Combined with the local part of the name,
|
||||
* this is used to uniquely identify a type of element
|
||||
* @param name Name of this element, which may include a prefix
|
||||
*/
|
||||
protected DomElement(DomDocument owner, String namespaceURI, String name)
|
||||
{
|
||||
super(ELEMENT_NODE, owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the element's attributes
|
||||
*/
|
||||
public NamedNodeMap getAttributes()
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
attributes = new DomNamedNodeMap(this, Node.ATTRIBUTE_NODE);
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2></b>
|
||||
* Returns true iff this is an element node with attributes.
|
||||
*/
|
||||
public boolean hasAttributes()
|
||||
{
|
||||
return attributes != null && attributes.length != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shallow clone of the element, except that associated
|
||||
* attributes are (deep) cloned.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
DomElement node = (DomElement) super.clone();
|
||||
|
||||
if (attributes != null)
|
||||
{
|
||||
node.attributes = new DomNamedNodeMap(node, Node.ATTRIBUTE_NODE);
|
||||
for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
node.attributes.setNamedItemNS(ctx.cloneNode(true));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
void setOwner(DomDocument doc)
|
||||
{
|
||||
if (attributes != null)
|
||||
{
|
||||
for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
ctx.setOwner(doc);
|
||||
}
|
||||
}
|
||||
super.setOwner(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks this element, its children, and its associated attributes as
|
||||
* readonly.
|
||||
*/
|
||||
public void makeReadonly()
|
||||
{
|
||||
super.makeReadonly();
|
||||
if (attributes != null)
|
||||
{
|
||||
attributes.makeReadonly();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the element name (same as getNodeName).
|
||||
*/
|
||||
final public String getTagName()
|
||||
{
|
||||
return getNodeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the value of the specified attribute, or an
|
||||
* empty string.
|
||||
*/
|
||||
public String getAttribute(String name)
|
||||
{
|
||||
if ("xml:space" == name) // NB only works on interned string
|
||||
{
|
||||
// Use cached value
|
||||
return xmlSpace;
|
||||
}
|
||||
Attr attr = getAttributeNode(name);
|
||||
return (attr == null) ? "" : attr.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns true if the element has an attribute with the
|
||||
* specified name (specified or DTD defaulted).
|
||||
*/
|
||||
public boolean hasAttribute(String name)
|
||||
{
|
||||
return getAttributeNode(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns true if the element has an attribute with the
|
||||
* specified name (specified or DTD defaulted).
|
||||
*/
|
||||
public boolean hasAttributeNS(String namespaceURI, String local)
|
||||
{
|
||||
return getAttributeNodeNS(namespaceURI, local) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the value of the specified attribute, or an
|
||||
* empty string.
|
||||
*/
|
||||
public String getAttributeNS(String namespaceURI, String local)
|
||||
{
|
||||
Attr attr = getAttributeNodeNS(namespaceURI, local);
|
||||
return (attr == null) ? "" : attr.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the appropriate attribute node; the name is the
|
||||
* nodeName property of the attribute.
|
||||
*/
|
||||
public Attr getAttributeNode(String name)
|
||||
{
|
||||
return (attributes == null) ? null :
|
||||
(Attr) attributes.getNamedItem(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the appropriate attribute node; the name combines
|
||||
* the namespace name and the local part.
|
||||
*/
|
||||
public Attr getAttributeNodeNS(String namespace, String localPart)
|
||||
{
|
||||
return (attributes == null) ? null :
|
||||
(Attr) attributes.getNamedItemNS(namespace, localPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Modifies an existing attribute to have the specified value,
|
||||
* or creates a new one with that value. The name used is the
|
||||
* nodeName value.
|
||||
*/
|
||||
public void setAttribute(String name, String value)
|
||||
{
|
||||
Attr attr = getAttributeNode(name);
|
||||
if (attr != null)
|
||||
{
|
||||
attr.setNodeValue(value);
|
||||
((DomAttr) attr).setSpecified(true);
|
||||
return;
|
||||
}
|
||||
attr = owner.createAttribute(name);
|
||||
attr.setNodeValue(value);
|
||||
setAttributeNode(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Modifies an existing attribute to have the specified value,
|
||||
* or creates a new one with that value.
|
||||
*/
|
||||
public void setAttributeNS(String uri, String aname, String value)
|
||||
{
|
||||
if (("xmlns".equals (aname) || aname.startsWith ("xmlns:"))
|
||||
&& !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (uri))
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"setting xmlns attribute to illegal value", this, 0);
|
||||
}
|
||||
|
||||
Attr attr = getAttributeNodeNS(uri, aname);
|
||||
if (attr != null)
|
||||
{
|
||||
attr.setNodeValue(value);
|
||||
return;
|
||||
}
|
||||
attr = owner.createAttributeNS(uri, aname);
|
||||
attr.setNodeValue(value);
|
||||
setAttributeNodeNS(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Stores the specified attribute, optionally overwriting any
|
||||
* existing one with that name.
|
||||
*/
|
||||
public Attr setAttributeNode(Attr attr)
|
||||
{
|
||||
return (Attr) getAttributes().setNamedItem(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Stores the specified attribute, optionally overwriting any
|
||||
* existing one with that name.
|
||||
*/
|
||||
public Attr setAttributeNodeNS(Attr attr)
|
||||
{
|
||||
return (Attr) getAttributes().setNamedItemNS(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Removes the appropriate attribute node.
|
||||
* If there is no such node, this is (bizarrely enough) a NOP so you
|
||||
* won't see exceptions if your code deletes non-existent attributes.
|
||||
*
|
||||
* <p>Note that since there is no portable way for DOM to record
|
||||
* DTD information, default values for attributes will never be
|
||||
* provided automatically.
|
||||
*/
|
||||
public void removeAttribute(String name)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
attributes.removeNamedItem(name);
|
||||
}
|
||||
catch (DomDOMException e)
|
||||
{
|
||||
if (e.code != DOMException.NOT_FOUND_ERR)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Removes the appropriate attribute node; the name is the
|
||||
* nodeName property of the attribute.
|
||||
*
|
||||
* <p>Note that since there is no portable way for DOM to record
|
||||
* DTD information, default values for attributes will never be
|
||||
* provided automatically.
|
||||
*/
|
||||
public Attr removeAttributeNode(Attr node)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR, null, node, 0);
|
||||
}
|
||||
return (Attr) attributes.removeNamedItem(node.getNodeName());
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Removes the appropriate attribute node; the name combines
|
||||
* the namespace name and the local part.
|
||||
*
|
||||
* <p>Note that since there is no portable way for DOM to record
|
||||
* DTD information, default values for attributes will never be
|
||||
* provided automatically.
|
||||
*/
|
||||
public void removeAttributeNS(String namespace, String localPart)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR, localPart, null, 0);
|
||||
}
|
||||
attributes.removeNamedItemNS (namespace, localPart);
|
||||
}
|
||||
|
||||
// DOM Level 3 methods
|
||||
|
||||
public String lookupPrefix(String namespaceURI)
|
||||
{
|
||||
if (namespaceURI == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String namespace = getNamespaceURI();
|
||||
if (namespace != null && namespace.equals(namespaceURI))
|
||||
{
|
||||
return getPrefix();
|
||||
}
|
||||
if (attributes != null)
|
||||
{
|
||||
for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
|
||||
.equals(ctx.getNamespaceURI()))
|
||||
{
|
||||
String value = ctx.getNodeValue();
|
||||
if (value.equals(namespaceURI))
|
||||
{
|
||||
return ctx.getLocalName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.lookupPrefix(namespaceURI);
|
||||
}
|
||||
|
||||
public boolean isDefaultNamespace(String namespaceURI)
|
||||
{
|
||||
String namespace = getNamespaceURI();
|
||||
if (namespace != null && namespace.equals(namespaceURI))
|
||||
{
|
||||
return getPrefix() == null;
|
||||
}
|
||||
if (attributes != null)
|
||||
{
|
||||
for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
|
||||
.equals(ctx.getNamespaceURI()))
|
||||
{
|
||||
String qName = ctx.getNodeName();
|
||||
return (XMLConstants.XMLNS_ATTRIBUTE.equals(qName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.isDefaultNamespace(namespaceURI);
|
||||
}
|
||||
|
||||
public String lookupNamespaceURI(String prefix)
|
||||
{
|
||||
String namespace = getNamespaceURI();
|
||||
if (namespace != null && equal(prefix, getPrefix()))
|
||||
{
|
||||
return namespace;
|
||||
}
|
||||
if (attributes != null)
|
||||
{
|
||||
for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
|
||||
.equals(ctx.getNamespaceURI()))
|
||||
{
|
||||
if (prefix == null)
|
||||
{
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE.equals(ctx.getNodeName()))
|
||||
{
|
||||
return ctx.getNodeValue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prefix.equals(ctx.getLocalName()))
|
||||
{
|
||||
return ctx.getNodeValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.lookupNamespaceURI(prefix);
|
||||
}
|
||||
|
||||
public String getBaseURI()
|
||||
{
|
||||
if (attributes != null)
|
||||
{
|
||||
Node xmlBase =
|
||||
attributes.getNamedItemNS(XMLConstants.XML_NS_URI, "base");
|
||||
if (xmlBase != null)
|
||||
{
|
||||
return xmlBase.getNodeValue();
|
||||
}
|
||||
}
|
||||
return super.getBaseURI();
|
||||
}
|
||||
|
||||
public TypeInfo getSchemaTypeInfo()
|
||||
{
|
||||
// DTD implementation
|
||||
DomDoctype doctype = (DomDoctype) owner.getDoctype();
|
||||
if (doctype != null)
|
||||
{
|
||||
return doctype.getElementTypeInfo(getNodeName());
|
||||
}
|
||||
// TODO XML Schema implementation
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setIdAttribute(String name, boolean isId)
|
||||
{
|
||||
NamedNodeMap attrs = getAttributes();
|
||||
Attr attr = (Attr) attrs.getNamedItem(name);
|
||||
setIdAttributeNode(attr, isId);
|
||||
}
|
||||
|
||||
public void setIdAttributeNode(Attr attr, boolean isId)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
if (attr == null || attr.getOwnerElement() != this)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
if (isId)
|
||||
{
|
||||
if (userIdAttrs == null)
|
||||
{
|
||||
userIdAttrs = new HashSet();
|
||||
}
|
||||
userIdAttrs.add(attr);
|
||||
}
|
||||
else if (userIdAttrs != null)
|
||||
{
|
||||
userIdAttrs.remove(attr);
|
||||
if (userIdAttrs.isEmpty())
|
||||
{
|
||||
userIdAttrs = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdAttributeNS(String namespaceURI, String localName,
|
||||
boolean isId)
|
||||
{
|
||||
NamedNodeMap attrs = getAttributes();
|
||||
Attr attr = (Attr) attrs.getNamedItemNS(namespaceURI, localName);
|
||||
setIdAttributeNode(attr, isId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/* DomEntity.java --
|
||||
Copyright (C) 1999,2000,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Entity;
|
||||
|
||||
/**
|
||||
* <p> "Entity" implementation. This is a non-core DOM class, supporting the
|
||||
* "XML" feature. There are two types of entities, neither of which works
|
||||
* particularly well in this API:</p><dl>
|
||||
*
|
||||
* <dt><em>Unparsed Entities</em></dt>
|
||||
* <dd>Since ENTITY/ENTITIES attributes, the only legal use of unparsed
|
||||
* entities in XML, can't be detected with DOM, there isn't much point in
|
||||
* trying to use unparsed entities in DOM applications. (XML Linking is
|
||||
* working to provide a better version of this functionality.) </dd>
|
||||
*
|
||||
* <dt><em>Parsed Entities</em></dt>
|
||||
* <dd> While the DOM specification permits nodes for parsed entities
|
||||
* to have a readonly set of children, this is not required and there
|
||||
* is no portable way to provide such children. <em>This implementation
|
||||
* currently does not permit children to be added to Entities.</em>
|
||||
* There are related issues with the use of EntityReference nodes. </dd>
|
||||
*
|
||||
* </dl>
|
||||
*
|
||||
* <p> In short, <em>avoid using this DOM functionality</em>.
|
||||
*
|
||||
* @see DomDoctype
|
||||
* @see DomEntityReference
|
||||
* @see DomNotation
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomEntity
|
||||
extends DomExtern
|
||||
implements Entity
|
||||
{
|
||||
|
||||
private String notation;
|
||||
|
||||
/**
|
||||
* Constructs an Entity node associated with the specified document,
|
||||
* with the specified descriptive data.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a DomDoctype as part
|
||||
* of its declareEntity functionality, or through a subclass which is
|
||||
* similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* @param owner The document with which this entity is associated
|
||||
* @param name Name of this entity
|
||||
* @param publicId If non-null, provides the entity's PUBLIC identifier
|
||||
* @param systemId Provides the entity's SYSTEM identifier (URI)
|
||||
* @param notation If non-null, provides the unparsed entity's notation.
|
||||
*/
|
||||
protected DomEntity(DomDocument owner,
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId,
|
||||
String notation)
|
||||
{
|
||||
super(ENTITY_NODE, owner, name, publicId, systemId);
|
||||
this.notation = notation;
|
||||
|
||||
// NOTE: if notation == null, this is a parsed entity
|
||||
// which could reasonably be given child nodes ...
|
||||
makeReadonly();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the NOTATION identifier associated with this entity, if any.
|
||||
*/
|
||||
final public String getNotationName()
|
||||
{
|
||||
return notation;
|
||||
}
|
||||
|
||||
// DOM Level 3 methods
|
||||
|
||||
public String getInputEncoding()
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getXmlEncoding()
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getXmlVersion()
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI of an external entity is its system ID.
|
||||
* The base URI of an internal entity is the parent document's base URI.
|
||||
* @since DOM Level 3 Core
|
||||
*/
|
||||
public String getBaseURI()
|
||||
{
|
||||
String systemId = getSystemId();
|
||||
return (systemId == null) ? owner.getBaseURI() : systemId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/* DomEntityReference.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Entity;
|
||||
import org.w3c.dom.EntityReference;
|
||||
|
||||
/**
|
||||
* <p> "EntityReference" implementation (reference to parsed entity).
|
||||
* This is a non-core DOM class, supporting the "XML" feature.
|
||||
* It does not represent builtin entities (such as "&amp;")
|
||||
* or character references, which are always directly expanded in
|
||||
* DOM trees.</p>
|
||||
*
|
||||
* <p> Note that while the DOM specification permits these nodes to have
|
||||
* a readonly set of children, this is not required. Similarly, it does
|
||||
* not require a DOM to couple EntityReference nodes with any Entity nodes
|
||||
* that have the same entity name (and equivalent children). It also
|
||||
* effectively guarantees that references created directly or indirectly
|
||||
* through the <em>Document.ImportNode</em> method will not have children.
|
||||
* The level of functionality you may get is extremely variable.
|
||||
*
|
||||
* <p> Also significant is that even at their most functional level, the fact
|
||||
* that EntityReference children must be readonly has caused significant
|
||||
* problems when modifying work products held in DOM trees. Other problems
|
||||
* include issues related to undeclared namespace prefixes (and references
|
||||
* to the current default namespace) that may be found in the text of such
|
||||
* parsed entities nodes. These must be contextually bound as part of DOM
|
||||
* tree construction. When such nodes are moved, the namespace associated
|
||||
* with a given prefix (or default) may change to be in conflict with the
|
||||
* namespace bound to the node at creation time.
|
||||
*
|
||||
* <p> In short, <em>avoid using this DOM functionality</em>.
|
||||
*
|
||||
* @see DomDoctype
|
||||
* @see DomEntity
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomEntityReference
|
||||
extends DomNode
|
||||
implements EntityReference
|
||||
{
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Constructs an EntityReference node associated with the specified
|
||||
* document. The creator should populate this with whatever contents
|
||||
* are appropriate, and then mark it as readonly.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document as part of
|
||||
* its createEntityReference functionality, or through a subclass which
|
||||
* is similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* @see DomNode#makeReadonly
|
||||
*/
|
||||
protected DomEntityReference(DomDocument owner, String name)
|
||||
{
|
||||
super(ENTITY_REFERENCE_NODE, owner);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the referenced entity.
|
||||
* @since DOM Level 1 Core
|
||||
*/
|
||||
public final String getNodeName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI of an entity reference is the base URI where the entity
|
||||
* declaration occurs.
|
||||
* @since DOM Level 3 Core
|
||||
*/
|
||||
public final String getBaseURI()
|
||||
{
|
||||
DocumentType doctype = owner.getDoctype();
|
||||
if (doctype == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Entity entity = (Entity) doctype.getEntities().getNamedItem(name);
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return entity.getBaseURI();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
/* DomEvent.java --
|
||||
Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.events.*;
|
||||
import org.w3c.dom.views.AbstractView; // used by UIEvent
|
||||
|
||||
/**
|
||||
* "Event" implementation. Events are
|
||||
* created (through DocumentEvent interface methods on the document object),
|
||||
* and are sent to any target node in the document.
|
||||
*
|
||||
* <p> Applications may define application specific event subclasses, but
|
||||
* should otherwise use the <em>DocumentTraversal</em> interface to acquire
|
||||
* event objects.
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public class DomEvent
|
||||
implements Event
|
||||
{
|
||||
|
||||
String type; // init
|
||||
EventTarget target;
|
||||
EventTarget currentNode;
|
||||
short eventPhase;
|
||||
boolean bubbles; // init
|
||||
boolean cancelable; // init
|
||||
long timeStamp; // ?
|
||||
|
||||
/** Returns the event's type (name) as initialized */
|
||||
public final String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns event's target; delivery of an event is initiated
|
||||
* by a <em>target.dispatchEvent(event)</em> invocation.
|
||||
*/
|
||||
public final EventTarget getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target to which events are currently being
|
||||
* delivered. When capturing or bubbling, this will not
|
||||
* be what <em>getTarget</em> returns.
|
||||
*/
|
||||
public final EventTarget getCurrentTarget()
|
||||
{
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns CAPTURING_PHASE, AT_TARGET, or BUBBLING;
|
||||
* only meaningful within EventListener.handleEvent
|
||||
*/
|
||||
public final short getEventPhase()
|
||||
{
|
||||
return eventPhase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the news of the event bubbles to tree tops
|
||||
* (as specified during initialization).
|
||||
*/
|
||||
public final boolean getBubbles()
|
||||
{
|
||||
return bubbles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the default handling may be canceled
|
||||
* (as specified during initialization).
|
||||
*/
|
||||
public final boolean getCancelable()
|
||||
{
|
||||
return cancelable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event's timestamp.
|
||||
*/
|
||||
public final long getTimeStamp()
|
||||
{
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
boolean stop;
|
||||
boolean doDefault;
|
||||
|
||||
/**
|
||||
* Requests the event no longer be captured or bubbled; only
|
||||
* listeners on the event target will see the event, if they
|
||||
* haven't yet been notified.
|
||||
*
|
||||
* <p> <em> Avoid using this </em> except for application-specific
|
||||
* events, for which you the protocol explicitly "blesses" the use
|
||||
* of this with some event types. Otherwise, you are likely to break
|
||||
* algorithms which depend on event notification either directly or
|
||||
* through bubbling or capturing. </p>
|
||||
*
|
||||
* <p> Note that this method is not final, specifically to enable
|
||||
* enforcing of policies about events always propagating. </p>
|
||||
*/
|
||||
public void stopPropagation()
|
||||
{
|
||||
stop = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that whoever dispatched the event not perform their
|
||||
* default processing when event delivery completes. Initializes
|
||||
* event timestamp.
|
||||
*/
|
||||
public final void preventDefault()
|
||||
{
|
||||
doDefault = false;
|
||||
}
|
||||
|
||||
/** Initializes basic event state. */
|
||||
public void initEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg)
|
||||
{
|
||||
eventPhase = 0;
|
||||
type = typeArg;
|
||||
bubbles = canBubbleArg;
|
||||
cancelable = cancelableArg;
|
||||
timeStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/** Constructs, but does not initialize, an event. */
|
||||
public DomEvent(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a basic printable description of the event's type,
|
||||
* state, and delivery conditions
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("[Event ");
|
||||
buf.append(type);
|
||||
switch (eventPhase)
|
||||
{
|
||||
case CAPTURING_PHASE:
|
||||
buf.append(", CAPTURING");
|
||||
break;
|
||||
case AT_TARGET:
|
||||
buf.append(", AT TARGET");
|
||||
break;
|
||||
case BUBBLING_PHASE:
|
||||
buf.append(", BUBBLING");
|
||||
break;
|
||||
default:
|
||||
buf.append(", (inactive)");
|
||||
break;
|
||||
}
|
||||
if (bubbles && eventPhase != BUBBLING_PHASE)
|
||||
{
|
||||
buf.append(", bubbles");
|
||||
}
|
||||
if (cancelable)
|
||||
{
|
||||
buf.append(", can cancel");
|
||||
}
|
||||
// were we to provide subclass info, this's where it'd live
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* "MutationEvent" implementation.
|
||||
*/
|
||||
public static final class DomMutationEvent
|
||||
extends DomEvent
|
||||
implements MutationEvent
|
||||
{
|
||||
|
||||
// package private
|
||||
Node relatedNode; // init
|
||||
|
||||
private String prevValue; // init
|
||||
private String newValue; // init
|
||||
|
||||
private String attrName; // init
|
||||
private short attrChange; // init
|
||||
|
||||
/** Returns any "related" node provided by this type of event */
|
||||
public final Node getRelatedNode()
|
||||
{
|
||||
return relatedNode;
|
||||
}
|
||||
|
||||
/** Returns any "previous value" provided by this type of event */
|
||||
public final String getPrevValue()
|
||||
{
|
||||
return prevValue;
|
||||
}
|
||||
|
||||
/** Returns any "new value" provided by this type of event */
|
||||
public final String getNewValue()
|
||||
{
|
||||
return newValue;
|
||||
}
|
||||
|
||||
/** For attribute change events, returns the attribute's name */
|
||||
public final String getAttrName()
|
||||
{
|
||||
return attrName;
|
||||
}
|
||||
|
||||
/** For attribute change events, returns how the attribuet changed */
|
||||
public final short getAttrChange()
|
||||
{
|
||||
return attrChange;
|
||||
}
|
||||
|
||||
/** Initializes a mutation event */
|
||||
public final void initMutationEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
Node relatedNodeArg,
|
||||
String prevValueArg,
|
||||
String newValueArg,
|
||||
String attrNameArg,
|
||||
short attrChangeArg)
|
||||
{
|
||||
// super.initEvent is inlined here for speed
|
||||
// (mutation events are issued on all DOM changes)
|
||||
eventPhase = 0;
|
||||
type = typeArg;
|
||||
bubbles = canBubbleArg;
|
||||
cancelable = cancelableArg;
|
||||
timeStamp = System.currentTimeMillis();
|
||||
|
||||
relatedNode = relatedNodeArg;
|
||||
prevValue = prevValueArg;
|
||||
newValue = newValueArg;
|
||||
attrName = attrNameArg;
|
||||
attrChange = attrChangeArg;
|
||||
}
|
||||
|
||||
// clear everything that should be GC-able
|
||||
void clear()
|
||||
{
|
||||
type = null;
|
||||
target = null;
|
||||
relatedNode = null;
|
||||
currentNode = null;
|
||||
prevValue = newValue = attrName = null;
|
||||
}
|
||||
|
||||
/** Constructs an uninitialized mutation event. */
|
||||
public DomMutationEvent(String type)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* "UIEvent" implementation.
|
||||
*/
|
||||
public static class DomUIEvent
|
||||
extends DomEvent
|
||||
implements UIEvent
|
||||
{
|
||||
|
||||
private AbstractView view; // init
|
||||
private int detail; // init
|
||||
|
||||
/** Constructs an uninitialized User Interface (UI) event */
|
||||
public DomUIEvent (String type) { super (type); }
|
||||
|
||||
public final AbstractView getView () { return view; }
|
||||
public final int getDetail () { return detail; }
|
||||
|
||||
/** Initializes a UI event */
|
||||
public final void initUIEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
AbstractView viewArg,
|
||||
int detailArg)
|
||||
{
|
||||
super.initEvent(typeArg, canBubbleArg, cancelableArg);
|
||||
view = viewArg;
|
||||
detail = detailArg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
static final class DomMouseEvent extends DomUIEvent
|
||||
implements MouseEvent
|
||||
{
|
||||
// another half dozen state variables/accessors
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/* DomExtern.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
/**
|
||||
* <p> Abstract implemention of nodes describing external DTD-related
|
||||
* objects. This facilitates reusing code for Entity, Notation, and
|
||||
* DocumentType (really, external subset) nodes. Such support is not
|
||||
* part of the core DOM; it's for the "XML" feature. </p>
|
||||
*
|
||||
* <p> Note that you are strongly advised to avoid using the DOM
|
||||
* features that take advantage of this class, since (as of L2) none
|
||||
* of them is defined fully enough to permit full use of the
|
||||
* XML feature they partially expose. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class DomExtern
|
||||
extends DomNode
|
||||
{
|
||||
|
||||
private final String name;
|
||||
private final String publicId;
|
||||
private final String systemId;
|
||||
|
||||
/**
|
||||
* Constructs a node associated with the specified document,
|
||||
* with the specified descriptive data.
|
||||
*
|
||||
* @param owner The document with which this object is associated
|
||||
* @param name Name of this object
|
||||
* @param publicId If non-null, provides the entity's PUBLIC identifier
|
||||
* @param systemId If non-null, provides the entity's SYSTEM identifier
|
||||
*/
|
||||
// package private
|
||||
DomExtern(short nodeType,
|
||||
DomDocument owner,
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId)
|
||||
{
|
||||
super(nodeType, owner);
|
||||
this.name = name;
|
||||
this.publicId = publicId;
|
||||
this.systemId = systemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the SYSTEM identifier associated with this object, if any.
|
||||
*/
|
||||
public final String getSystemId()
|
||||
{
|
||||
return systemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the PUBLIC identifier associated with this object, if any.
|
||||
*/
|
||||
public final String getPublicId()
|
||||
{
|
||||
return publicId;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the object's name.
|
||||
*/
|
||||
public final String getNodeName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public final String getLocalName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/* DomImpl.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSInput;
|
||||
import org.w3c.dom.ls.LSOutput;
|
||||
import org.w3c.dom.ls.LSParser;
|
||||
import org.w3c.dom.ls.LSSerializer;
|
||||
import gnu.xml.dom.html2.DomHTMLImpl;
|
||||
import gnu.xml.dom.ls.DomLSInput;
|
||||
import gnu.xml.dom.ls.DomLSOutput;
|
||||
import gnu.xml.dom.ls.DomLSParser;
|
||||
import gnu.xml.dom.ls.DomLSSerializer;
|
||||
|
||||
/**
|
||||
* <p> "DOMImplementation" implementation. </p>
|
||||
*
|
||||
* <p> At this writing, the following features are supported:
|
||||
* "XML" (L1, L2, L3),
|
||||
* "Events" (L2), "MutationEvents" (L2), "USER-Events" (a conformant extension),
|
||||
* "HTMLEvents" (L2), "UIEvents" (L2), "Traversal" (L2), "XPath" (L3),
|
||||
* "LS" (L3) "LS-Async" (L3).
|
||||
* It is possible to compile the package so it doesn't support some of these
|
||||
* features (notably, Traversal).
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomImpl
|
||||
implements DOMImplementation, DOMImplementationLS
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a DOMImplementation object which supports
|
||||
* "XML" and other DOM Level 2 features.
|
||||
*/
|
||||
public DomImpl()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns true if the specified feature and version are
|
||||
* supported. Note that the case of the feature name is ignored.
|
||||
*/
|
||||
public boolean hasFeature(String name, String version)
|
||||
{
|
||||
if (name.length() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
name = name.toLowerCase();
|
||||
if (name.charAt(0) == '+')
|
||||
{
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
if ("xml".equals(name) || "core".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"1.0".equals(version) ||
|
||||
"2.0".equals(version) ||
|
||||
"3.0".equals(version));
|
||||
|
||||
}
|
||||
else if ("ls".equals(name) || "ls-async".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"3.0".equals(version));
|
||||
}
|
||||
else if ("events".equals(name)
|
||||
|| "mutationevents".equals(name)
|
||||
|| "uievents".equals(name)
|
||||
// || "mouseevents".equals(name)
|
||||
|| "htmlevents".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"2.0".equals(version));
|
||||
|
||||
// Extension: "USER-" prefix event types can
|
||||
// be created and passed through the DOM.
|
||||
|
||||
}
|
||||
else if ("user-events".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"0.1".equals(version));
|
||||
|
||||
// NOTE: "hasFeature" for events is here interpreted to
|
||||
// mean the DOM can manufacture those sorts of events,
|
||||
// since actually choosing to report the events is more
|
||||
// often part of the environment or application. It's
|
||||
// only really an issue for mutation events.
|
||||
|
||||
}
|
||||
else if (DomNode.reportMutations
|
||||
&& "traversal".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"2.0".equals(version));
|
||||
}
|
||||
else if ("xpath".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"3.0".equals(version));
|
||||
}
|
||||
else if ("html".equals(name) || "xhtml".equals(name))
|
||||
{
|
||||
return (version == null ||
|
||||
"".equals(version) ||
|
||||
"2.0".equals(version));
|
||||
}
|
||||
|
||||
// views
|
||||
// stylesheets
|
||||
// css, css2
|
||||
// range
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Creates and returns a DocumentType, associated with this
|
||||
* implementation. This DocumentType can have no associated
|
||||
* objects(notations, entities) until the DocumentType is
|
||||
* first associated with a document.
|
||||
*
|
||||
* <p> Note that there is no implication that this DTD will
|
||||
* be parsed by the DOM, or ever have contents. Moreover, the
|
||||
* DocumentType created here can only be added to a document by
|
||||
* the createDocument method(below). <em>That means that the only
|
||||
* portable way to create a Document object is to start parsing,
|
||||
* queue comment and processing instruction (PI) nodes, and then only
|
||||
* create a DOM Document after <b>(a)</b> it's known if a DocumentType
|
||||
* object is needed, and <b>(b) the name and namespace of the root
|
||||
* element is known. Queued comment and PI nodes would then be
|
||||
* inserted appropriately in the document prologue, both before and
|
||||
* after the DTD node, and additional attributes assigned to the
|
||||
* root element.</em>
|
||||
*(One hopes that the final DOM REC fixes this serious botch.)
|
||||
*/
|
||||
public DocumentType createDocumentType(String rootName,
|
||||
String publicId,
|
||||
String systemId)
|
||||
// CR2 deleted internal subset, ensuring DocumentType
|
||||
// is 100% useless instead of just 90% so.
|
||||
{
|
||||
DomDocument.checkNCName(rootName, false);
|
||||
return new DomDoctype(this, rootName, publicId, systemId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Creates and returns a Document, populated only with a root element and
|
||||
* optionally a document type(if that was provided).
|
||||
*/
|
||||
public Document createDocument(String namespaceURI,
|
||||
String rootName,
|
||||
DocumentType doctype)
|
||||
{
|
||||
Document doc = createDocument();
|
||||
Element root = null;
|
||||
|
||||
if (rootName != null)
|
||||
{
|
||||
root = doc.createElementNS(namespaceURI, rootName);
|
||||
if (rootName.startsWith("xmlns:"))
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"xmlns is reserved", null, 0);
|
||||
}
|
||||
}
|
||||
// Bleech -- L2 seemingly _requires_ omission of xmlns attributes.
|
||||
if (doctype != null)
|
||||
{
|
||||
doc.appendChild(doctype); // handles WRONG_DOCUMENT error
|
||||
}
|
||||
if (root != null)
|
||||
{
|
||||
doc.appendChild(root);
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
protected Document createDocument()
|
||||
{
|
||||
return new DomDocument(this);
|
||||
}
|
||||
|
||||
// DOM Level 3
|
||||
|
||||
public Object getFeature(String feature, String version)
|
||||
{
|
||||
if (hasFeature(feature, version))
|
||||
{
|
||||
if ("html".equalsIgnoreCase(feature) ||
|
||||
"xhtml".equalsIgnoreCase(feature))
|
||||
{
|
||||
return new DomHTMLImpl();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// -- DOMImplementationLS --
|
||||
|
||||
public LSParser createLSParser(short mode, String schemaType)
|
||||
throws DOMException
|
||||
{
|
||||
return new DomLSParser(mode, schemaType);
|
||||
}
|
||||
|
||||
public LSSerializer createLSSerializer()
|
||||
{
|
||||
return new DomLSSerializer();
|
||||
}
|
||||
|
||||
public LSInput createLSInput()
|
||||
{
|
||||
return new DomLSInput();
|
||||
}
|
||||
|
||||
public LSOutput createLSOutput()
|
||||
{
|
||||
return new DomLSOutput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
/* DomIterator.java --
|
||||
Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.events.EventListener;
|
||||
import org.w3c.dom.events.EventTarget;
|
||||
import org.w3c.dom.events.MutationEvent;
|
||||
import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.NodeIterator;
|
||||
|
||||
/**
|
||||
* <p> "NodeIterator" implementation, usable with any L2 DOM which
|
||||
* supports MutationEvents. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public final class DomIterator
|
||||
implements NodeIterator, EventListener
|
||||
{
|
||||
|
||||
private Node reference;
|
||||
private boolean right;
|
||||
private boolean done;
|
||||
|
||||
private final Node root;
|
||||
private final int whatToShow;
|
||||
private final NodeFilter filter;
|
||||
private final boolean expandEntityReferences;
|
||||
|
||||
/**
|
||||
* Constructs and initializes an iterator.
|
||||
*/
|
||||
protected DomIterator(Node root,
|
||||
int whatToShow,
|
||||
NodeFilter filter,
|
||||
boolean entityReferenceExpansion)
|
||||
{
|
||||
if (!root.isSupported("MutationEvents", "2.0"))
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
|
||||
"Iterator needs mutation events", root, 0);
|
||||
}
|
||||
|
||||
this.root = root;
|
||||
this.whatToShow = whatToShow;
|
||||
this.filter = filter;
|
||||
this.expandEntityReferences = entityReferenceExpansion;
|
||||
|
||||
// start condition: going right, seen nothing yet.
|
||||
reference = null;
|
||||
right = true;
|
||||
|
||||
EventTarget target = (EventTarget) root;
|
||||
target.addEventListener("DOMNodeRemoved", this, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Flags the iterator as done, unregistering its event listener so
|
||||
* that the iterator can be garbage collected without relying on weak
|
||||
* references (a "Java 2" feature) in the event subsystem.
|
||||
*/
|
||||
public void detach()
|
||||
{
|
||||
EventTarget target = (EventTarget) root;
|
||||
target.removeEventListener("DOMNodeRemoved", this, false);
|
||||
done = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the flag controlling whether iteration descends
|
||||
* through entity references.
|
||||
*/
|
||||
public boolean getExpandEntityReferences()
|
||||
{
|
||||
return expandEntityReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the filter provided during construction.
|
||||
*/
|
||||
public NodeFilter getFilter()
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the root of the tree this is iterating through.
|
||||
*/
|
||||
public Node getRoot()
|
||||
{
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the mask of flags provided during construction.
|
||||
*/
|
||||
public int getWhatToShow()
|
||||
{
|
||||
return whatToShow;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the next node in a forward iteration, masked and filtered.
|
||||
* Note that the node may be read-only due to entity expansions.
|
||||
* A null return indicates the iteration is complete, but may still
|
||||
* be processed backwards.
|
||||
*/
|
||||
public Node nextNode()
|
||||
{
|
||||
if (done)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INVALID_STATE_ERR);
|
||||
}
|
||||
right = true;
|
||||
return walk(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the next node in a backward iteration, masked and filtered.
|
||||
* Note that the node may be read-only due to entity expansions.
|
||||
* A null return indicates the iteration is complete, but may still
|
||||
* be processed forwards.
|
||||
*/
|
||||
public Node previousNode()
|
||||
{
|
||||
if (done)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INVALID_STATE_ERR);
|
||||
}
|
||||
Node previous = reference;
|
||||
right = false;
|
||||
walk(false);
|
||||
return previous;
|
||||
}
|
||||
|
||||
private boolean shouldShow(Node node)
|
||||
// raises Runtime exceptions indirectly, via acceptNode()
|
||||
{
|
||||
if ((whatToShow & (1 << (node.getNodeType() - 1))) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (filter == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT;
|
||||
}
|
||||
|
||||
//
|
||||
// scenario: root = 1, sequence = 1 2 ... 3 4
|
||||
// forward walk: 1 2 ... 3 4 null
|
||||
// then backward: 4 3 ... 2 1 null
|
||||
//
|
||||
// At the leftmost end, "previous" == null
|
||||
// At the rightmost end, "previous" == 4
|
||||
//
|
||||
// The current draft spec really seem to make no sense re the
|
||||
// role of the reference node, so what it says is ignored here.
|
||||
//
|
||||
private Node walk(boolean forward)
|
||||
{
|
||||
Node here = reference;
|
||||
|
||||
while ((here = successor(here, forward)) != null
|
||||
&& !shouldShow(here))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (here != null || !forward)
|
||||
{
|
||||
reference = here;
|
||||
}
|
||||
return here;
|
||||
}
|
||||
|
||||
private boolean isLeaf(Node here)
|
||||
{
|
||||
boolean leaf = !here.hasChildNodes();
|
||||
if (!leaf && !expandEntityReferences)
|
||||
{
|
||||
leaf = (here.getNodeType() == Node.ENTITY_REFERENCE_NODE);
|
||||
}
|
||||
return leaf;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the immediate successor in a forward (or backward)
|
||||
// document order walk, sans filtering ... except that it knows
|
||||
// how to stop, returning null when done. This is a depth first
|
||||
// preorder traversal when run in the forward direction.
|
||||
//
|
||||
private Node successor(Node here, boolean forward)
|
||||
{
|
||||
Node next;
|
||||
|
||||
// the "leftmost" end is funky
|
||||
if (here == null)
|
||||
{
|
||||
return forward ? root : null;
|
||||
}
|
||||
|
||||
//
|
||||
// Forward, this is preorder: children before siblings.
|
||||
// Backward, it's postorder: we saw the children already.
|
||||
//
|
||||
if (forward && !isLeaf(here))
|
||||
{
|
||||
return here.getFirstChild();
|
||||
}
|
||||
|
||||
//
|
||||
// Siblings ... if forward, we visit them, if backwards
|
||||
// we visit their children first.
|
||||
//
|
||||
if (forward)
|
||||
{
|
||||
if ((next = here.getNextSibling()) != null)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
}
|
||||
else if ((next = here.getPreviousSibling()) != null)
|
||||
{
|
||||
if (isLeaf(next))
|
||||
{
|
||||
return next;
|
||||
}
|
||||
next = next.getLastChild();
|
||||
while (!isLeaf(next))
|
||||
{
|
||||
next = next.getLastChild();
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
//
|
||||
// We can't go down or lateral -- it's up, then. The logic is
|
||||
// the converse of what's above: backwards is easy (the parent
|
||||
// is next), forwards isn't.
|
||||
//
|
||||
next = here.getParentNode();
|
||||
if (!forward)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
Node temp = null;
|
||||
while (next != null
|
||||
&& next != root
|
||||
&& (temp = next.getNextSibling()) == null)
|
||||
{
|
||||
next = next.getParentNode();
|
||||
}
|
||||
if (next == root)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not for public use. This lets the iterator know when its
|
||||
* reference node will be removed from the tree, so that a new
|
||||
* one may be selected.
|
||||
*
|
||||
* <p> This version works by watching removal events as they
|
||||
* bubble up. So, don't prevent them from bubbling.
|
||||
*/
|
||||
public void handleEvent(Event e)
|
||||
{
|
||||
MutationEvent event;
|
||||
Node ancestor, removed;
|
||||
|
||||
if (reference == null
|
||||
|| !"DOMNodeRemoved".equals(e.getType())
|
||||
|| e.getEventPhase() != Event.BUBBLING_PHASE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event = (MutationEvent) e;
|
||||
removed = (Node) event.getTarget();
|
||||
|
||||
// See if the removal will cause trouble for this iterator
|
||||
// by being the reference node or an ancestor of it.
|
||||
for (ancestor = reference;
|
||||
ancestor != null && ancestor != root;
|
||||
ancestor = ancestor.getParentNode())
|
||||
{
|
||||
if (ancestor == removed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ancestor != removed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// OK, it'll cause trouble. We want to make the "next"
|
||||
// node in our current traversal direction seem right.
|
||||
// So we pick the nearest node that's not getting removed,
|
||||
// but go in the _opposite_ direction from our current
|
||||
// traversal ... so the "next" doesn't skip anything.
|
||||
Node candidate;
|
||||
|
||||
search:
|
||||
while ((candidate = walk(!right)) != null)
|
||||
{
|
||||
for (ancestor = candidate;
|
||||
ancestor != null && ancestor != root;
|
||||
ancestor = ancestor.getParentNode())
|
||||
{
|
||||
if (ancestor == removed)
|
||||
{
|
||||
continue search;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// The current DOM WD talks about a special case here;
|
||||
// I've not yet seen it.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* DomNSResolverContext.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import org.w3c.dom.xpath.XPathNSResolver;
|
||||
|
||||
/**
|
||||
* Namespace content wrapper for an XPathNSResolver.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomNSResolverContext
|
||||
implements NamespaceContext, Iterator
|
||||
{
|
||||
|
||||
final XPathNSResolver resolver;
|
||||
|
||||
DomNSResolverContext(XPathNSResolver resolver)
|
||||
{
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
public String getNamespaceURI(String prefix)
|
||||
{
|
||||
return resolver.lookupNamespaceURI(prefix);
|
||||
}
|
||||
|
||||
public String getPrefix(String namespaceURI)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getPrefixes(String namespaceURI)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasNext()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object next()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
/* DomNamedNodeMap.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* <p> "NamedNodeMap" implementation. </p>
|
||||
* Used mostly to hold element attributes, but sometimes also
|
||||
* to list notations or entities.
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomNamedNodeMap
|
||||
implements NamedNodeMap
|
||||
{
|
||||
|
||||
final DomNode owner;
|
||||
final short type;
|
||||
|
||||
DomNode first;
|
||||
int length;
|
||||
boolean readonly;
|
||||
|
||||
// package private
|
||||
DomNamedNodeMap(DomNode owner, short type)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposes the internal "readonly" flag. In DOM, all NamedNodeMap
|
||||
* objects found in a DocumentType object are read-only (after
|
||||
* they are fully constructed), and those holding attributes of
|
||||
* a readonly element will also be readonly.
|
||||
*/
|
||||
public final boolean isReadonly()
|
||||
{
|
||||
return readonly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal "readonly" flag so the node and its
|
||||
* children can't be changed.
|
||||
*/
|
||||
public void makeReadonly()
|
||||
{
|
||||
readonly = true;
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
ctx.makeReadonly();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the named item from the map, or null; names are just
|
||||
* the nodeName property.
|
||||
*/
|
||||
public Node getNamedItem(String name)
|
||||
{
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
if (ctx.getNodeName().equals(name))
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the named item from the map, or null; names are the
|
||||
* localName and namespaceURI properties, ignoring any prefix.
|
||||
*/
|
||||
public Node getNamedItemNS(String namespaceURI, String localName)
|
||||
{
|
||||
if ("".equals(namespaceURI))
|
||||
{
|
||||
namespaceURI = null;
|
||||
}
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
String name = ctx.getLocalName();
|
||||
if ((localName == null && name == null) ||
|
||||
(localName != null && localName.equals(name)))
|
||||
{
|
||||
String uri = ctx.getNamespaceURI();
|
||||
if ("".equals(uri))
|
||||
{
|
||||
uri = null;
|
||||
}
|
||||
if ((namespaceURI == null && uri == null) ||
|
||||
(namespaceURI != null && namespaceURI.equals(uri)))
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Stores the named item into the map, optionally overwriting
|
||||
* any existing node with that name. The name used is just
|
||||
* the nodeName attribute.
|
||||
*/
|
||||
public Node setNamedItem(Node arg)
|
||||
{
|
||||
return setNamedItem(arg, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Stores the named item into the map, optionally overwriting
|
||||
* any existing node with that fully qualified name. The name
|
||||
* used incorporates the localName and namespaceURI properties,
|
||||
* and ignores any prefix.
|
||||
*/
|
||||
public Node setNamedItemNS(Node arg)
|
||||
{
|
||||
return setNamedItem(arg, true);
|
||||
}
|
||||
|
||||
Node setNamedItem(Node arg, boolean ns)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
|
||||
DomNode node = (DomNode) arg;
|
||||
if (node.owner != owner.owner)
|
||||
{
|
||||
throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
|
||||
}
|
||||
if (node.nodeType != type)
|
||||
{
|
||||
throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
if (node.nodeType == Node.ATTRIBUTE_NODE)
|
||||
{
|
||||
DomNode element = node.parent;
|
||||
if (element != null && element != owner)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
|
||||
}
|
||||
node.parent = owner;
|
||||
node.depth = owner.depth + 1;
|
||||
}
|
||||
|
||||
String nodeName = node.getNodeName();
|
||||
String localName = ns ? node.getLocalName() : null;
|
||||
String namespaceURI = ns ? node.getNamespaceURI() : null;
|
||||
if ("".equals(namespaceURI))
|
||||
{
|
||||
namespaceURI = null;
|
||||
}
|
||||
|
||||
// maybe attribute ADDITION events (?)
|
||||
DomNode last = null;
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
boolean test = false;
|
||||
if (ns)
|
||||
{
|
||||
String tln = ctx.getLocalName();
|
||||
if (tln == null)
|
||||
{
|
||||
tln = ctx.getNodeName();
|
||||
}
|
||||
if (tln.equals(localName))
|
||||
{
|
||||
String tu = ctx.getNamespaceURI();
|
||||
if ((tu == null && namespaceURI == null) ||
|
||||
(tu != null && tu.equals(namespaceURI)))
|
||||
{
|
||||
test = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test = ctx.getNodeName().equals(nodeName);
|
||||
}
|
||||
if (test)
|
||||
{
|
||||
// replace
|
||||
node.previous = ctx.previous;
|
||||
node.next = ctx.next;
|
||||
if (ctx.previous != null)
|
||||
{
|
||||
ctx.previous.next = node;
|
||||
}
|
||||
if (ctx.next != null)
|
||||
{
|
||||
ctx.next.previous = node;
|
||||
}
|
||||
if (first == ctx)
|
||||
{
|
||||
first = node;
|
||||
}
|
||||
reparent(node, nodeName, ctx.index);
|
||||
ctx.parent = null;
|
||||
ctx.next = null;
|
||||
ctx.previous = null;
|
||||
ctx.setDepth(0);
|
||||
ctx.index = 0;
|
||||
return ctx;
|
||||
}
|
||||
last = ctx;
|
||||
}
|
||||
// append
|
||||
if (last != null)
|
||||
{
|
||||
last.next = node;
|
||||
node.previous = last;
|
||||
}
|
||||
else
|
||||
{
|
||||
first = node;
|
||||
}
|
||||
length++;
|
||||
reparent(node, nodeName, 0);
|
||||
return null;
|
||||
}
|
||||
|
||||
void reparent(DomNode node, String nodeName, int i)
|
||||
{
|
||||
node.parent = owner;
|
||||
node.setDepth(owner.depth + 1);
|
||||
// index renumbering
|
||||
for (DomNode ctx = node; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
ctx.index = i++;
|
||||
}
|
||||
// cache xml:space
|
||||
boolean xmlSpace = "xml:space".equals(nodeName);
|
||||
if (xmlSpace && owner instanceof DomElement)
|
||||
{
|
||||
((DomElement) owner).xmlSpace = node.getNodeValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Removes the named item from the map, or reports an exception;
|
||||
* names are just the nodeName property.
|
||||
*/
|
||||
public Node removeNamedItem(String name)
|
||||
{
|
||||
return removeNamedItem(null, name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Removes the named item from the map, or reports an exception;
|
||||
* names are the localName and namespaceURI properties.
|
||||
*/
|
||||
public Node removeNamedItemNS(String namespaceURI, String localName)
|
||||
{
|
||||
return removeNamedItem(namespaceURI, localName, true);
|
||||
}
|
||||
|
||||
Node removeNamedItem(String uri, String name, boolean ns)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
|
||||
// report attribute REMOVAL event?
|
||||
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
boolean test = false;
|
||||
String nodeName = ctx.getNodeName();
|
||||
if (ns)
|
||||
{
|
||||
String tln = ctx.getLocalName();
|
||||
if (tln.equals(name))
|
||||
{
|
||||
String tu = ctx.getNamespaceURI();
|
||||
if ((tu == null && uri == null) ||
|
||||
(tu != null && tu.equals(uri)))
|
||||
{
|
||||
test = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test = nodeName.equals(name);
|
||||
}
|
||||
if (test)
|
||||
{
|
||||
// uncache xml:space
|
||||
boolean xmlSpace = "xml:space".equals(nodeName);
|
||||
if (xmlSpace && owner instanceof DomElement)
|
||||
{
|
||||
((DomElement) owner).xmlSpace = "";
|
||||
}
|
||||
// is this a default attribute?
|
||||
if (ctx.nodeType == Node.ATTRIBUTE_NODE)
|
||||
{
|
||||
String def = getDefaultValue(ctx.getNodeName());
|
||||
if (def != null)
|
||||
{
|
||||
ctx.setNodeValue(def);
|
||||
((DomAttr) ctx).setSpecified(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// remove
|
||||
if (ctx == first)
|
||||
{
|
||||
first = ctx.next;
|
||||
}
|
||||
if (ctx.previous != null)
|
||||
{
|
||||
ctx.previous.next = ctx.next;
|
||||
}
|
||||
if (ctx.next != null)
|
||||
{
|
||||
ctx.next.previous = ctx.previous;
|
||||
}
|
||||
length--;
|
||||
ctx.previous = null;
|
||||
ctx.next = null;
|
||||
ctx.parent = null;
|
||||
ctx.setDepth(0);
|
||||
ctx.index = 0;
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
|
||||
String getDefaultValue(String name)
|
||||
{
|
||||
DomDoctype doctype = (DomDoctype) owner.owner.getDoctype();
|
||||
if (doctype == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DTDAttributeTypeInfo info =
|
||||
doctype.getAttributeTypeInfo(owner.getNodeName(), name);
|
||||
if (info == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return info.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the indexed item from the map, or null.
|
||||
*/
|
||||
public Node item(int index)
|
||||
{
|
||||
DomNode ctx = first;
|
||||
int count = 0;
|
||||
while (ctx != null && count < index)
|
||||
{
|
||||
ctx = ctx.next;
|
||||
count++;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the length of the map.
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,327 @@
|
||||
/* DomNodeIterator.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.NodeIterator;
|
||||
import org.w3c.dom.traversal.TreeWalker;
|
||||
|
||||
/**
|
||||
* Node iterator and tree walker.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomNodeIterator
|
||||
implements NodeIterator, TreeWalker
|
||||
{
|
||||
|
||||
Node root;
|
||||
final int whatToShow;
|
||||
final NodeFilter filter;
|
||||
final boolean entityReferenceExpansion;
|
||||
final boolean walk;
|
||||
Node current;
|
||||
|
||||
public DomNodeIterator(Node root, int whatToShow, NodeFilter filter,
|
||||
boolean entityReferenceExpansion, boolean walk)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root");
|
||||
}
|
||||
this.root = root;
|
||||
this.whatToShow = whatToShow;
|
||||
this.filter = filter;
|
||||
this.entityReferenceExpansion = entityReferenceExpansion;
|
||||
this.walk = walk;
|
||||
current = root;
|
||||
}
|
||||
|
||||
public Node getRoot()
|
||||
{
|
||||
return root;
|
||||
}
|
||||
|
||||
public int getWhatToShow()
|
||||
{
|
||||
return whatToShow;
|
||||
}
|
||||
|
||||
public NodeFilter getFilter()
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
|
||||
public boolean getExpandEntityReferences()
|
||||
{
|
||||
return entityReferenceExpansion;
|
||||
}
|
||||
|
||||
public Node nextNode()
|
||||
throws DOMException
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
throw new DOMException(DOMException.INVALID_STATE_ERR, "null root");
|
||||
}
|
||||
Node ret;
|
||||
do
|
||||
{
|
||||
if (current.equals(root))
|
||||
{
|
||||
ret = root.getFirstChild();
|
||||
}
|
||||
else if (walk)
|
||||
{
|
||||
ret = current.getFirstChild();
|
||||
if (ret == null)
|
||||
{
|
||||
ret = current.getNextSibling();
|
||||
}
|
||||
if (ret == null)
|
||||
{
|
||||
Node tmp = current;
|
||||
ret = tmp.getParentNode();
|
||||
while (!ret.equals(root) && tmp.equals(ret.getLastChild()))
|
||||
{
|
||||
tmp = ret;
|
||||
ret = tmp.getParentNode();
|
||||
}
|
||||
if (ret.equals(root))
|
||||
{
|
||||
ret = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ret.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = current.getNextSibling();
|
||||
}
|
||||
}
|
||||
while (!accept(ret));
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node previousNode()
|
||||
throws DOMException
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
throw new DOMException(DOMException.INVALID_STATE_ERR, "null root");
|
||||
}
|
||||
Node ret;
|
||||
do
|
||||
{
|
||||
if (current.equals(root))
|
||||
{
|
||||
ret = current.getLastChild();
|
||||
}
|
||||
else if (walk)
|
||||
{
|
||||
ret = current.getLastChild();
|
||||
if (ret == null)
|
||||
{
|
||||
ret = current.getPreviousSibling();
|
||||
}
|
||||
if (ret == null)
|
||||
{
|
||||
Node tmp = current;
|
||||
ret = tmp.getParentNode();
|
||||
while (!ret.equals(root) && tmp.equals(ret.getFirstChild()))
|
||||
{
|
||||
tmp = ret;
|
||||
ret = tmp.getParentNode();
|
||||
}
|
||||
if (ret.equals(root))
|
||||
{
|
||||
ret = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ret.getPreviousSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = current.getPreviousSibling();
|
||||
}
|
||||
}
|
||||
while (!accept(ret));
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node getCurrentNode()
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrentNode(Node current)
|
||||
throws DOMException
|
||||
{
|
||||
if (current == null)
|
||||
{
|
||||
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root");
|
||||
}
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public Node parentNode()
|
||||
{
|
||||
Node ret = current.getParentNode();
|
||||
if (!accept (ret))
|
||||
{
|
||||
ret = null;
|
||||
}
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node firstChild ()
|
||||
{
|
||||
Node ret = current.getFirstChild();
|
||||
while (!accept(ret))
|
||||
{
|
||||
ret = ret.getNextSibling();
|
||||
}
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node lastChild()
|
||||
{
|
||||
Node ret = current.getLastChild();
|
||||
while (!accept(ret))
|
||||
{
|
||||
ret = ret.getPreviousSibling();
|
||||
}
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node previousSibling()
|
||||
{
|
||||
Node ret = current.getPreviousSibling();
|
||||
while (!accept(ret))
|
||||
{
|
||||
ret = ret.getPreviousSibling();
|
||||
}
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Node nextSibling()
|
||||
{
|
||||
Node ret = current.getNextSibling();
|
||||
while (!accept(ret))
|
||||
{
|
||||
ret = ret.getNextSibling();
|
||||
}
|
||||
current = (ret == null) ? current : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void detach()
|
||||
{
|
||||
root = null;
|
||||
}
|
||||
|
||||
boolean accept(Node node)
|
||||
{
|
||||
if (node == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
boolean ret;
|
||||
switch (node.getNodeType())
|
||||
{
|
||||
case Node.ATTRIBUTE_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_ATTRIBUTE) != 0;
|
||||
break;
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_CDATA_SECTION) != 0;
|
||||
break;
|
||||
case Node.COMMENT_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_COMMENT) != 0;
|
||||
break;
|
||||
case Node.DOCUMENT_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_DOCUMENT) != 0;
|
||||
break;
|
||||
case Node.DOCUMENT_FRAGMENT_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT) != 0;
|
||||
break;
|
||||
case Node.DOCUMENT_TYPE_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_TYPE) != 0;
|
||||
break;
|
||||
case Node.ELEMENT_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_ELEMENT) != 0;
|
||||
break;
|
||||
case Node.ENTITY_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_ENTITY) != 0;
|
||||
break;
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_ENTITY_REFERENCE) != 0;
|
||||
ret = ret && entityReferenceExpansion;
|
||||
break;
|
||||
case Node.NOTATION_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_NOTATION) != 0;
|
||||
break;
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_PROCESSING_INSTRUCTION) != 0;
|
||||
break;
|
||||
case Node.TEXT_NODE:
|
||||
ret = (whatToShow & NodeFilter.SHOW_TEXT) != 0;
|
||||
break;
|
||||
default:
|
||||
ret = true;
|
||||
}
|
||||
if (ret && filter != null)
|
||||
{
|
||||
ret = (filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* DomNotation.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Notation;
|
||||
|
||||
/**
|
||||
* <p> "Notation" implementation. This is a non-core DOM class, supporting
|
||||
* the "XML" feature. </p>
|
||||
*
|
||||
* <p> Although unparsed entities using this notation can be detected using
|
||||
* DOM, neither NOTATIONS nor ENTITY/ENTITIES attributes can be so detected.
|
||||
* More, there is no portable way to construct a Notation node, so there's
|
||||
* no way that vendor-neutral DOM construction APIs could even report a
|
||||
* NOTATION used to identify the intended meaning of a ProcessingInstruction.
|
||||
* </p>
|
||||
*
|
||||
* <p> In short, <em>avoid using this DOM functionality</em>.
|
||||
*
|
||||
* @see DomDoctype
|
||||
* @see DomEntity
|
||||
* @see DomPI
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomNotation
|
||||
extends DomExtern
|
||||
implements Notation
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a Notation node associated with the specified document,
|
||||
* with the specified descriptive data. Note that at least one of
|
||||
* the PUBLIC and SYSTEM identifiers must be provided; unlike other
|
||||
* external objects in XML, notations may have only a PUBLIC identifier.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a DomDoctype object
|
||||
* as part of its declareNotation functionality, or through a subclass
|
||||
* which is similarly used in a "Sub-DOM" style layer.
|
||||
*
|
||||
* @param owner The document with which this notation is associated
|
||||
* @param name Name of this notation
|
||||
* @param publicId If non-null, provides the notation's PUBLIC identifier
|
||||
* @param systemId If non-null, rovides the notation's SYSTEM identifier
|
||||
*/
|
||||
protected DomNotation(DomDocument owner,
|
||||
String name,
|
||||
String publicId,
|
||||
String systemId)
|
||||
{
|
||||
super(NOTATION_NODE, owner, name, publicId, systemId);
|
||||
makeReadonly();
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI of an external entity is its system ID.
|
||||
* The base URI of an internal entity is the parent document's base URI.
|
||||
* @since DOM Level 3 Core
|
||||
*/
|
||||
public String getBaseURI()
|
||||
{
|
||||
String systemId = getSystemId();
|
||||
return (systemId == null) ? owner.getBaseURI() : systemId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/* DomNsNode.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import org.w3c.dom.DOMException;
|
||||
|
||||
/**
|
||||
* <p> Abstract implemention of namespace support. This facilitates
|
||||
* sharing code for attribute and element nodes.
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class DomNsNode
|
||||
extends DomNode
|
||||
{
|
||||
|
||||
private String name;
|
||||
private String namespace;
|
||||
private String prefix;
|
||||
String localName;
|
||||
|
||||
/**
|
||||
* Constructs a node associated with the specified document, and
|
||||
* with the specified namespace information.
|
||||
*
|
||||
* @param owner The document with which this entity is associated
|
||||
* @param namespaceURI Combined with the local part of the name,
|
||||
* this identifies a type of element or attribute; may be null.
|
||||
* If this is the empty string, it is reassigned as null so that
|
||||
* applications only need to test that case.
|
||||
* @param name Name of this node, which may include a prefix
|
||||
*/
|
||||
// package private
|
||||
DomNsNode(short nodeType, DomDocument owner, String namespaceURI, String name)
|
||||
{
|
||||
super(nodeType, owner);
|
||||
setNodeName(name);
|
||||
setNamespaceURI(namespaceURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the node's name, including any namespace prefix.
|
||||
*/
|
||||
public final String getNodeName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
final void setNodeName(String name)
|
||||
{
|
||||
this.name = name.intern();
|
||||
int index = name.indexOf(':');
|
||||
if (index == -1)
|
||||
{
|
||||
prefix = null;
|
||||
localName = this.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = name.substring(0, index).intern();
|
||||
localName = name.substring(index + 1).intern();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the node's namespace URI
|
||||
* <em>or null</em> if the node name is not namespace scoped.
|
||||
*/
|
||||
public final String getNamespaceURI()
|
||||
{
|
||||
return namespace;
|
||||
}
|
||||
|
||||
final void setNamespaceURI(String namespaceURI)
|
||||
{
|
||||
if ("".equals(namespaceURI))
|
||||
{
|
||||
namespaceURI = null;
|
||||
}
|
||||
namespace = (namespaceURI == null) ? null : namespaceURI.intern();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns any prefix part of the node's name (before any colon).
|
||||
*/
|
||||
public final String getPrefix()
|
||||
{
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Assigns the prefix part of the node's name (before any colon).
|
||||
*/
|
||||
public final void setPrefix(String prefix)
|
||||
{
|
||||
if (readonly)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
|
||||
if (prefix == null)
|
||||
{
|
||||
name = localName;
|
||||
return;
|
||||
}
|
||||
else if (namespace == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"can't set prefix, node has no namespace URI",
|
||||
this, 0);
|
||||
}
|
||||
|
||||
DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion()));
|
||||
if (prefix.indexOf (':') != -1)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"illegal prefix " + prefix, this, 0);
|
||||
}
|
||||
|
||||
if (XMLConstants.XML_NS_PREFIX.equals(prefix)
|
||||
&& !XMLConstants.XML_NS_URI.equals(namespace))
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"xml namespace is always " +
|
||||
XMLConstants.XML_NS_URI, this, 0);
|
||||
}
|
||||
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))
|
||||
{
|
||||
if (namespace != null || getNodeType() != ATTRIBUTE_NODE)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"xmlns attribute prefix is reserved",
|
||||
this, 0);
|
||||
}
|
||||
}
|
||||
else if (getNodeType () == ATTRIBUTE_NODE
|
||||
&& (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
|
||||
name.startsWith("xmlns:")))
|
||||
{
|
||||
throw new DomDOMException(DOMException.NAMESPACE_ERR,
|
||||
"namespace declarations can't change names",
|
||||
this, 0);
|
||||
}
|
||||
|
||||
this.prefix = prefix.intern();
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L2</b>
|
||||
* Returns the local part of the node's name (after any colon).
|
||||
*/
|
||||
public final String getLocalName()
|
||||
{
|
||||
return localName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/* DomProcessingInstruction.java --
|
||||
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.ProcessingInstruction;
|
||||
|
||||
/**
|
||||
* <p> "ProcessingInstruction" (PI) implementation.
|
||||
* This is a non-core DOM class, supporting the "XML" feature. </p>
|
||||
*
|
||||
* <p> Unlike other DOM APIs in the "XML" feature, this one fully
|
||||
* exposes the functionality it describes. So there is no reason
|
||||
* inherent in DOM to avoid using this API, unless you want to rely
|
||||
* on NOTATION declarations to associate meaning with your PIs;
|
||||
* there is no vendor-neutal way to record those notations in DOM.</p>
|
||||
*
|
||||
* <p> Also of note is that PI support is part of SAX, so that XML
|
||||
* systems using PIs can choose among multiple APIs. </p>
|
||||
*
|
||||
* @see DomNotation
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomProcessingInstruction
|
||||
extends DomNode
|
||||
implements ProcessingInstruction
|
||||
{
|
||||
|
||||
private String target;
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* Constructs a ProcessingInstruction node associated with the
|
||||
* specified document, with the specified data.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document object as
|
||||
* part of its createProcessingInstruction functionality, or through
|
||||
* a subclass which is similarly used in a "Sub-DOM" style layer.
|
||||
*/
|
||||
protected DomProcessingInstruction(DomDocument owner,
|
||||
String target, String data)
|
||||
{
|
||||
super(PROCESSING_INSTRUCTION_NODE, owner);
|
||||
this.target = target;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the target of the processing instruction.
|
||||
*/
|
||||
public final String getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the target of the processing instruction
|
||||
* (same as getTarget).
|
||||
*/
|
||||
public final String getNodeName()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the data associated with the processing instruction.
|
||||
*/
|
||||
public final String getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the data associated with the processing instruction
|
||||
* (same as getData).
|
||||
*/
|
||||
public final String getNodeValue()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the data associated with the processing instruction;
|
||||
* same as setNodeValue.
|
||||
*/
|
||||
public final void setData(String data)
|
||||
{
|
||||
setNodeValue(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Assigns the data associated with the processing instruction.
|
||||
*/
|
||||
public final void setNodeValue(String data)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/* DomText.java --
|
||||
Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* <p> "Text" implementation. </p>
|
||||
*
|
||||
* @author David Brownell
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomText
|
||||
extends DomCharacterData
|
||||
implements Text
|
||||
{
|
||||
|
||||
// NOTE: deleted unused per-instance "isIgnorable"
|
||||
// support to reclaim its space.
|
||||
|
||||
/**
|
||||
* Constructs a text node associated with the specified
|
||||
* document and holding the specified data.
|
||||
*
|
||||
* <p>This constructor should only be invoked by a Document object
|
||||
* as part of its createTextNode functionality, or through a subclass
|
||||
* which is similarly used in a "Sub-DOM" style layer.
|
||||
*/
|
||||
protected DomText(DomDocument owner, String value)
|
||||
{
|
||||
super(TEXT_NODE, owner, value);
|
||||
}
|
||||
|
||||
protected DomText(DomDocument owner, char[] buf, int off, int len)
|
||||
{
|
||||
super(TEXT_NODE, owner, buf, off, len);
|
||||
}
|
||||
|
||||
// Used by DomCDATA
|
||||
DomText(short nodeType, DomDocument owner, String value)
|
||||
{
|
||||
super(nodeType, owner, value);
|
||||
}
|
||||
|
||||
DomText(short nodeType, DomDocument owner, char[] buf, int off, int len)
|
||||
{
|
||||
super(nodeType, owner, buf, off, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Returns the string "#text".
|
||||
*/
|
||||
// can't be 'final' with CDATA subclassing
|
||||
public String getNodeName()
|
||||
{
|
||||
return "#text";
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>DOM L1</b>
|
||||
* Splits this text node in two parts at the offset, returning
|
||||
* the new text node (the sibling with the second part).
|
||||
*/
|
||||
public Text splitText(int offset)
|
||||
{
|
||||
if (isReadonly())
|
||||
{
|
||||
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
try
|
||||
{
|
||||
String text = getNodeValue();
|
||||
String before = text.substring(0, offset);
|
||||
String after = text.substring(offset);
|
||||
Text next;
|
||||
|
||||
if (getNodeType() == TEXT_NODE)
|
||||
{
|
||||
next = owner.createTextNode(after);
|
||||
}
|
||||
else // CDATA_SECTION_NODE
|
||||
{
|
||||
next = owner.createCDATASection(after);
|
||||
}
|
||||
|
||||
if (this.next != null)
|
||||
{
|
||||
parent.insertBefore(next, this.next);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.appendChild(next);
|
||||
}
|
||||
setNodeValue(before);
|
||||
return next;
|
||||
|
||||
}
|
||||
catch (IndexOutOfBoundsException x)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// DOM Level 3
|
||||
|
||||
public boolean isElementContentWhitespace()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
DomDoctype doctype = (DomDoctype) owner.getDoctype();
|
||||
if (doctype != null)
|
||||
{
|
||||
DTDElementTypeInfo info =
|
||||
doctype.getElementTypeInfo(parent.getNodeName());
|
||||
if (info != null)
|
||||
{
|
||||
if (info.model == null && info.model.indexOf("#PCDATA") != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return getNodeValue().trim().length() == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getWholeText()
|
||||
{
|
||||
DomNode ref = this;
|
||||
DomNode ctx;
|
||||
for (ctx = previous; ctx != null &&
|
||||
(ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
|
||||
ctx = ctx.previous)
|
||||
{
|
||||
ref = ctx;
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(ref.getNodeValue());
|
||||
for (ctx = ref.next; ctx != null &&
|
||||
(ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
|
||||
ctx = ctx.next)
|
||||
{
|
||||
buf.append(ctx.getNodeValue());
|
||||
}
|
||||
return buf.toString ();
|
||||
}
|
||||
|
||||
public Text replaceWholeText(String content)
|
||||
throws DOMException
|
||||
{
|
||||
boolean isEmpty = (content == null || content.length () == 0);
|
||||
if (!isEmpty)
|
||||
{
|
||||
setNodeValue(content);
|
||||
}
|
||||
|
||||
DomNode ref = this;
|
||||
DomNode ctx;
|
||||
for (ctx = previous; ctx != null &&
|
||||
(ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
|
||||
ctx = ctx.previous)
|
||||
{
|
||||
ref = ctx;
|
||||
}
|
||||
ctx = ref.next;
|
||||
if ((isEmpty || ref != this) && parent != null)
|
||||
{
|
||||
parent.removeChild(ref);
|
||||
}
|
||||
for (; ctx != null &&
|
||||
(ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
|
||||
ctx = ref)
|
||||
{
|
||||
ref = ctx.next;
|
||||
if ((isEmpty || ctx != this) && parent != null)
|
||||
{
|
||||
parent.removeChild(ctx);
|
||||
}
|
||||
}
|
||||
return (isEmpty) ? null : this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/* DomXPathExpression.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.xpath.XPathException;
|
||||
import org.w3c.dom.xpath.XPathNSResolver;
|
||||
import org.w3c.dom.xpath.XPathResult;
|
||||
import gnu.xml.xpath.DocumentOrderComparator;
|
||||
|
||||
/**
|
||||
* An XPath expression.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomXPathExpression
|
||||
implements org.w3c.dom.xpath.XPathExpression
|
||||
{
|
||||
|
||||
final DomDocument doc;
|
||||
final XPathExpression expression;
|
||||
final XPathNSResolver resolver;
|
||||
|
||||
DomXPathExpression(DomDocument doc, String expression,
|
||||
XPathNSResolver resolver)
|
||||
throws XPathException
|
||||
{
|
||||
this.doc = doc;
|
||||
this.resolver = resolver;
|
||||
|
||||
XPathFactory factory = XPathFactory.newInstance();
|
||||
XPath xpath = factory.newXPath();
|
||||
if (resolver != null)
|
||||
{
|
||||
xpath.setNamespaceContext(new DomNSResolverContext(resolver));
|
||||
}
|
||||
try
|
||||
{
|
||||
this.expression = xpath.compile(expression);
|
||||
}
|
||||
catch (XPathExpressionException e)
|
||||
{
|
||||
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
|
||||
e.getMessage ());
|
||||
}
|
||||
}
|
||||
|
||||
public Object evaluate(Node contextNode, short type, Object result)
|
||||
throws XPathException, DOMException
|
||||
{
|
||||
try
|
||||
{
|
||||
QName typeName = null;
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.BOOLEAN_TYPE:
|
||||
typeName = XPathConstants.BOOLEAN;
|
||||
break;
|
||||
case XPathResult.NUMBER_TYPE:
|
||||
typeName = XPathConstants.NUMBER;
|
||||
break;
|
||||
case XPathResult.STRING_TYPE:
|
||||
typeName = XPathConstants.STRING;
|
||||
break;
|
||||
case XPathResult.ANY_UNORDERED_NODE_TYPE:
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
typeName = XPathConstants.NODE;
|
||||
break;
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
typeName = XPathConstants.NODESET;
|
||||
break;
|
||||
default:
|
||||
throw new XPathException(XPathException.TYPE_ERR, null);
|
||||
}
|
||||
Object val = expression.evaluate(contextNode, typeName);
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
// Sort the nodes
|
||||
List ns = new ArrayList((Collection) val);
|
||||
Collections.sort(ns, new DocumentOrderComparator());
|
||||
val = ns;
|
||||
}
|
||||
return new DomXPathResult(val, type);
|
||||
}
|
||||
catch (javax.xml.xpath.XPathException e)
|
||||
{
|
||||
throw new XPathException(XPathException.TYPE_ERR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return getClass ().getName () + "[expression=" + expression + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* DomXPathNSResolver.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.xpath.XPathNSResolver;
|
||||
|
||||
/**
|
||||
* Generic XPath namespace resolver using a DOM Node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomXPathNSResolver
|
||||
implements XPathNSResolver
|
||||
{
|
||||
|
||||
Node node;
|
||||
|
||||
DomXPathNSResolver (Node node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String lookupNamespaceURI (String prefix)
|
||||
{
|
||||
return node.lookupNamespaceURI (prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/* DomXPathResult.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.xpath.XPathException;
|
||||
import org.w3c.dom.xpath.XPathResult;
|
||||
|
||||
/**
|
||||
* An XPath result object.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomXPathResult
|
||||
implements XPathResult
|
||||
{
|
||||
|
||||
final Object value;
|
||||
final short type;
|
||||
Iterator iterator;
|
||||
|
||||
DomXPathResult (Object value, short requestedType)
|
||||
{
|
||||
this.value = value;
|
||||
if (value instanceof Boolean)
|
||||
{
|
||||
type = XPathResult.BOOLEAN_TYPE;
|
||||
}
|
||||
else if (value instanceof Double)
|
||||
{
|
||||
type = XPathResult.NUMBER_TYPE;
|
||||
}
|
||||
else if (value instanceof String)
|
||||
{
|
||||
type = XPathResult.STRING_TYPE;
|
||||
}
|
||||
else if (value instanceof Collection)
|
||||
{
|
||||
Collection ns = (Collection) value;
|
||||
switch (requestedType)
|
||||
{
|
||||
case XPathResult.ANY_TYPE:
|
||||
case XPathResult.ANY_UNORDERED_NODE_TYPE:
|
||||
type = (ns.size () == 1) ? XPathResult.FIRST_ORDERED_NODE_TYPE :
|
||||
XPathResult.ORDERED_NODE_ITERATOR_TYPE;
|
||||
break;
|
||||
default:
|
||||
type = requestedType;
|
||||
}
|
||||
iterator = ns.iterator ();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException ();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getBooleanValue()
|
||||
{
|
||||
if (type == XPathResult.BOOLEAN_TYPE)
|
||||
{
|
||||
return ((Boolean) value).booleanValue ();
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public boolean getInvalidIteratorState()
|
||||
{
|
||||
return iterator == null;
|
||||
}
|
||||
|
||||
public double getNumberValue()
|
||||
{
|
||||
if (type == XPathResult.NUMBER_TYPE)
|
||||
{
|
||||
return ((Double) value).doubleValue ();
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public short getResultType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public Node getSingleNodeValue()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
Collection ns = (Collection) value;
|
||||
if (ns.isEmpty ())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Node) ns.iterator ().next ();
|
||||
}
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public int getSnapshotLength()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
return ((Collection) value).size ();
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public String getStringValue()
|
||||
{
|
||||
if (type == XPathResult.STRING_TYPE)
|
||||
{
|
||||
return (String) value;
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public Node iterateNext()
|
||||
{
|
||||
if (iterator != null)
|
||||
{
|
||||
if (iterator.hasNext ())
|
||||
{
|
||||
return (Node) iterator.next ();
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public Node snapshotItem(int index)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
Collection ns = (Collection) value;
|
||||
Node[] nodes = new Node[ns.size ()];
|
||||
ns.toArray (nodes);
|
||||
return nodes[index];
|
||||
}
|
||||
throw new XPathException (XPathException.TYPE_ERR, value.toString ());
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return getClass ().getName () + "[type=" + typeName (type) + ",value=" +
|
||||
value + ']';
|
||||
}
|
||||
|
||||
private String typeName (short type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XPathResult.BOOLEAN_TYPE:
|
||||
return "BOOLEAN_TYPE";
|
||||
case XPathResult.NUMBER_TYPE:
|
||||
return "NUMBER_TYPE";
|
||||
case XPathResult.STRING_TYPE:
|
||||
return "STRING_TYPE";
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
return "FIRST_ORDERED_NODE_TYPE";
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
return "ORDERED_NODE_ITERATOR_TYPE";
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
return "ORDERED_NODE_SNAPSHOT_TYPE";
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
return "UNORDERED_NODE_ITERATOR_TYPE";
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
return "UNORDERED_NODE_SNAPSHOT_TYPE";
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/* ImplementationList.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc..
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.DOMImplementationList;
|
||||
|
||||
/**
|
||||
* Implementation list for GNU JAXP.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class ImplementationList
|
||||
implements DOMImplementationList
|
||||
{
|
||||
|
||||
private List list;
|
||||
|
||||
ImplementationList(List list)
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public DOMImplementation item(int index)
|
||||
{
|
||||
return (DOMImplementation) list.get(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ImplementationSource.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc..
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.DOMImplementationList;
|
||||
import org.w3c.dom.DOMImplementationSource;
|
||||
|
||||
/**
|
||||
* Implementation source for GNU JAXP.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class ImplementationSource
|
||||
implements DOMImplementationSource
|
||||
{
|
||||
|
||||
private static final String DIGITS = "1234567890";
|
||||
|
||||
/*
|
||||
* GNU DOM implementations.
|
||||
*/
|
||||
private static final DOMImplementation[] implementations;
|
||||
|
||||
static
|
||||
{
|
||||
List acc = new ArrayList();
|
||||
acc.add(new gnu.xml.dom.DomImpl());
|
||||
try
|
||||
{
|
||||
Class t = Class.forName("gnu.xml.libxmlj.dom.GnomeDocumentBuilder");
|
||||
acc.add(t.newInstance());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// libxmlj not available
|
||||
}
|
||||
catch (UnsatisfiedLinkError e)
|
||||
{
|
||||
// libxmlj not available
|
||||
}
|
||||
implementations = new DOMImplementation[acc.size()];
|
||||
acc.toArray(implementations);
|
||||
}
|
||||
|
||||
public DOMImplementation getDOMImplementation(String features)
|
||||
{
|
||||
List available = getImplementations(features);
|
||||
if (available.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (DOMImplementation) available.get(0);
|
||||
}
|
||||
|
||||
public DOMImplementationList getDOMImplementationList(String features)
|
||||
{
|
||||
List available = getImplementations(features);
|
||||
return new ImplementationList(available);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the implementations that support the specified
|
||||
* features.
|
||||
*/
|
||||
private final List getImplementations(String features)
|
||||
{
|
||||
List available = new ArrayList(Arrays.asList(implementations));
|
||||
for (Iterator i = parseFeatures(features).iterator(); i.hasNext(); )
|
||||
{
|
||||
String feature = (String) i.next();
|
||||
String version = null;
|
||||
int si = feature.indexOf(' ');
|
||||
if (si != -1)
|
||||
{
|
||||
version = feature.substring(si + 1);
|
||||
feature = feature.substring(0, si);
|
||||
}
|
||||
for (Iterator j = available.iterator(); j.hasNext(); )
|
||||
{
|
||||
DOMImplementation impl = (DOMImplementation) j.next();
|
||||
if (!impl.hasFeature(feature, version))
|
||||
{
|
||||
j.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return available;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the feature list into feature tokens.
|
||||
*/
|
||||
final List parseFeatures(String features)
|
||||
{
|
||||
List list = new ArrayList();
|
||||
int pos = 0, start = 0;
|
||||
int len = features.length();
|
||||
for (; pos < len; pos++)
|
||||
{
|
||||
char c = features.charAt(pos);
|
||||
if (c == ' ')
|
||||
{
|
||||
if (pos + 1 < len &&
|
||||
DIGITS.indexOf(features.charAt(pos + 1)) == -1)
|
||||
{
|
||||
list.add(getFeature(features, start, pos));
|
||||
start = pos + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pos > start)
|
||||
{
|
||||
list.add(getFeature(features, start, len));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
final String getFeature(String features, int start, int end)
|
||||
{
|
||||
if (features.length() > 0 && features.charAt(start) == '+')
|
||||
{
|
||||
return features.substring(start + 1, end);
|
||||
}
|
||||
return features.substring(start, end);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/* JAXPFactory.java --
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
|
||||
/**
|
||||
* DOM bootstrapping API, for use with JAXP.
|
||||
*
|
||||
* @see Consumer
|
||||
*
|
||||
* @author David Brownell
|
||||
*/
|
||||
public final class JAXPFactory
|
||||
extends DocumentBuilderFactory
|
||||
{
|
||||
|
||||
private static final String PROPERTY = "http://xml.org/sax/properties/";
|
||||
private static final String FEATURE = "http://xml.org/sax/features/";
|
||||
|
||||
private SAXParserFactory pf;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public JAXPFactory()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a JAXP document builder which uses the default
|
||||
* JAXP SAX2 parser and the DOM implementation in this package.
|
||||
*/
|
||||
public DocumentBuilder newDocumentBuilder()
|
||||
throws ParserConfigurationException
|
||||
{
|
||||
if (pf == null)
|
||||
{
|
||||
// Force use of AElfred2 since not all JAXP parsers
|
||||
// conform very well to the SAX2 API spec ...
|
||||
pf = new gnu.xml.aelfred2.JAXPFactory();
|
||||
// pf = SAXParserFactory.newInstance ();
|
||||
}
|
||||
|
||||
// JAXP default: false
|
||||
pf.setValidating(isValidating());
|
||||
|
||||
// FIXME: this namespace setup may cause errors in some
|
||||
// conformant SAX2 parsers, which we CAN patch up by
|
||||
// splicing a "NSFilter" stage up front ...
|
||||
|
||||
// JAXP default: false
|
||||
pf.setNamespaceAware(isNamespaceAware());
|
||||
|
||||
try
|
||||
{
|
||||
// undo rude "namespace-prefixes=false" default
|
||||
pf.setFeature(FEATURE + "namespace-prefixes", true);
|
||||
|
||||
return new JAXPBuilder(pf.newSAXParser().getXMLReader(), this);
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
String msg = "can't create JAXP DocumentBuilder: " + e.getMessage();
|
||||
throw new ParserConfigurationException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** There seems to be no useful specification for attribute names */
|
||||
public void setAttribute(String name, Object value)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if ("http://java.sun.com/xml/jaxp/properties/schemaLanguage".equals(name))
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException(name);
|
||||
}
|
||||
}
|
||||
|
||||
/** There seems to be no useful specification for attribute names */
|
||||
public Object getAttribute(String name)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
throw new IllegalArgumentException(name);
|
||||
}
|
||||
|
||||
static final class JAXPBuilder
|
||||
extends DocumentBuilder
|
||||
implements ErrorHandler
|
||||
{
|
||||
|
||||
private Consumer consumer;
|
||||
private XMLReader producer;
|
||||
private DomImpl impl;
|
||||
|
||||
JAXPBuilder(XMLReader parser, JAXPFactory factory)
|
||||
throws ParserConfigurationException
|
||||
{
|
||||
impl = new DomImpl();
|
||||
|
||||
// set up consumer side
|
||||
try
|
||||
{
|
||||
consumer = new Consumer();
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ParserConfigurationException(e.getMessage());
|
||||
}
|
||||
|
||||
// JAXP defaults: true, noise nodes are good (bleech)
|
||||
consumer.setHidingReferences(factory.isExpandEntityReferences());
|
||||
consumer.setHidingComments(factory.isIgnoringComments());
|
||||
consumer.setHidingWhitespace(factory.isIgnoringElementContentWhitespace());
|
||||
consumer.setHidingCDATA(factory.isCoalescing());
|
||||
|
||||
// set up producer side
|
||||
producer = parser;
|
||||
producer.setContentHandler(consumer.getContentHandler());
|
||||
producer.setDTDHandler(consumer.getDTDHandler());
|
||||
|
||||
try
|
||||
{
|
||||
String id;
|
||||
|
||||
// if validating, report validity errors, and default
|
||||
// to treating them as fatal
|
||||
if (factory.isValidating ())
|
||||
{
|
||||
producer.setFeature(FEATURE + "validation", true);
|
||||
producer.setErrorHandler(this);
|
||||
}
|
||||
|
||||
// always save prefix info, maybe do namespace processing
|
||||
producer.setFeature(FEATURE + "namespace-prefixes", true);
|
||||
producer.setFeature(FEATURE + "namespaces",
|
||||
factory.isNamespaceAware());
|
||||
|
||||
// set important handlers
|
||||
id = PROPERTY + "lexical-handler";
|
||||
producer.setProperty(id, consumer.getProperty(id));
|
||||
|
||||
id = PROPERTY + "declaration-handler";
|
||||
producer.setProperty(id, consumer.getProperty(id));
|
||||
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
throw new ParserConfigurationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Document parse(InputSource source)
|
||||
throws SAXException, IOException
|
||||
{
|
||||
producer.parse(source);
|
||||
Document doc = consumer.getDocument();
|
||||
// TODO inputEncoding
|
||||
doc.setDocumentURI(source.getSystemId());
|
||||
return doc;
|
||||
}
|
||||
|
||||
public boolean isNamespaceAware()
|
||||
{
|
||||
try
|
||||
{
|
||||
return producer.getFeature(FEATURE + "namespaces");
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
// "can't happen"
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidating()
|
||||
{
|
||||
try
|
||||
{
|
||||
return producer.getFeature(FEATURE + "validation");
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
// "can't happen"
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntityResolver(EntityResolver resolver)
|
||||
{
|
||||
producer.setEntityResolver(resolver);
|
||||
}
|
||||
|
||||
public void setErrorHandler(ErrorHandler handler)
|
||||
{
|
||||
producer.setErrorHandler(handler);
|
||||
consumer.setErrorHandler(handler);
|
||||
}
|
||||
|
||||
public DOMImplementation getDOMImplementation()
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
public Document newDocument()
|
||||
{
|
||||
return new DomDocument();
|
||||
}
|
||||
|
||||
// implementation of error handler that's used when validating
|
||||
public void fatalError(SAXParseException e)
|
||||
throws SAXException
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
||||
public void error(SAXParseException e)
|
||||
throws SAXException
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
||||
public void warning(SAXParseException e)
|
||||
throws SAXException
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
/* DomHTMLAnchorElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLAnchorElement;
|
||||
|
||||
/**
|
||||
* An HTML 'A' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLAnchorElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLAnchorElement
|
||||
{
|
||||
|
||||
protected DomHTMLAnchorElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public String getCharset()
|
||||
{
|
||||
return getHTMLAttribute("charset");
|
||||
}
|
||||
|
||||
public void setCharset(String charset)
|
||||
{
|
||||
setHTMLAttribute("charset", charset);
|
||||
}
|
||||
|
||||
public String getCoords()
|
||||
{
|
||||
return getHTMLAttribute("coords");
|
||||
}
|
||||
|
||||
public void setCoords(String coords)
|
||||
{
|
||||
setHTMLAttribute("coords", coords);
|
||||
}
|
||||
|
||||
public String getHref()
|
||||
{
|
||||
return getHTMLAttribute("href");
|
||||
}
|
||||
|
||||
public void setHref(String href)
|
||||
{
|
||||
setHTMLAttribute("href", href);
|
||||
}
|
||||
|
||||
public String getHreflang()
|
||||
{
|
||||
return getHTMLAttribute("hreflang");
|
||||
}
|
||||
|
||||
public void setHreflang(String hreflang)
|
||||
{
|
||||
setHTMLAttribute("hreflang", hreflang);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getRel()
|
||||
{
|
||||
return getHTMLAttribute("rel");
|
||||
}
|
||||
|
||||
public void setRel(String rel)
|
||||
{
|
||||
setHTMLAttribute("rel", rel);
|
||||
}
|
||||
|
||||
public String getRev()
|
||||
{
|
||||
return getHTMLAttribute("rev");
|
||||
}
|
||||
|
||||
public void setRev(String rev)
|
||||
{
|
||||
setHTMLAttribute("rev", rev);
|
||||
}
|
||||
|
||||
public String getShape()
|
||||
{
|
||||
return getHTMLAttribute("shape");
|
||||
}
|
||||
|
||||
public void setShape(String shape)
|
||||
{
|
||||
setHTMLAttribute("shape", shape);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return getHTMLAttribute("target");
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHTMLAttribute("target", target);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
public void blur()
|
||||
{
|
||||
dispatchUIEvent("blur");
|
||||
}
|
||||
|
||||
public void focus()
|
||||
{
|
||||
dispatchUIEvent("focus");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
/* DomHTMLAppletElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLAppletElement;
|
||||
|
||||
/**
|
||||
* An HTML 'APPLET' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLAppletElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLAppletElement
|
||||
{
|
||||
|
||||
protected DomHTMLAppletElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getAlt()
|
||||
{
|
||||
return getHTMLAttribute("alt");
|
||||
}
|
||||
|
||||
public void setAlt(String alt)
|
||||
{
|
||||
setHTMLAttribute("alt", alt);
|
||||
}
|
||||
|
||||
public String getArchive()
|
||||
{
|
||||
return getHTMLAttribute("archive");
|
||||
}
|
||||
|
||||
public void setArchive(String archive)
|
||||
{
|
||||
setHTMLAttribute("archive", archive);
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return getHTMLAttribute("code");
|
||||
}
|
||||
|
||||
public void setCode(String code)
|
||||
{
|
||||
setHTMLAttribute("code", code);
|
||||
}
|
||||
|
||||
public String getCodeBase()
|
||||
{
|
||||
return getHTMLAttribute("codebase");
|
||||
}
|
||||
|
||||
public void setCodeBase(String codeBase)
|
||||
{
|
||||
setHTMLAttribute("codebase", codeBase);
|
||||
}
|
||||
|
||||
public String getHeight()
|
||||
{
|
||||
return getHTMLAttribute("height");
|
||||
}
|
||||
|
||||
public void setHeight(String height)
|
||||
{
|
||||
setHTMLAttribute("height", height);
|
||||
}
|
||||
|
||||
public int getHspace()
|
||||
{
|
||||
return getIntHTMLAttribute("hspace");
|
||||
}
|
||||
|
||||
public void setHspace(int hspace)
|
||||
{
|
||||
setIntHTMLAttribute("hspace", hspace);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getObject()
|
||||
{
|
||||
return getHTMLAttribute("object");
|
||||
}
|
||||
|
||||
public void setObject(String object)
|
||||
{
|
||||
setHTMLAttribute("object", object);
|
||||
}
|
||||
|
||||
public int getVspace()
|
||||
{
|
||||
return getIntHTMLAttribute("vspace");
|
||||
}
|
||||
|
||||
public void setVspace(int vspace)
|
||||
{
|
||||
setIntHTMLAttribute("vspace", vspace);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/* DomHTMLAreaElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLAreaElement;
|
||||
|
||||
/**
|
||||
* An HTML 'AREA' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLAreaElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLAreaElement
|
||||
{
|
||||
|
||||
protected DomHTMLAreaElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public String getAlt()
|
||||
{
|
||||
return getHTMLAttribute("alt");
|
||||
}
|
||||
|
||||
public void setAlt(String alt)
|
||||
{
|
||||
setHTMLAttribute("alt", alt);
|
||||
}
|
||||
|
||||
public String getCoords()
|
||||
{
|
||||
return getHTMLAttribute("coords");
|
||||
}
|
||||
|
||||
public void setCoords(String coords)
|
||||
{
|
||||
setHTMLAttribute("coords", coords);
|
||||
}
|
||||
|
||||
public String getHref()
|
||||
{
|
||||
return getHTMLAttribute("href");
|
||||
}
|
||||
|
||||
public void setHref(String href)
|
||||
{
|
||||
setHTMLAttribute("href", href);
|
||||
}
|
||||
|
||||
public boolean getNoHref()
|
||||
{
|
||||
return getBooleanHTMLAttribute("nohref");
|
||||
}
|
||||
|
||||
public void setNoHref(boolean nohref)
|
||||
{
|
||||
setBooleanHTMLAttribute("nohref", nohref);
|
||||
}
|
||||
|
||||
public String getShape()
|
||||
{
|
||||
return getHTMLAttribute("shape");
|
||||
}
|
||||
|
||||
public void setShape(String shape)
|
||||
{
|
||||
setHTMLAttribute("shape", shape);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return getHTMLAttribute("target");
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHTMLAttribute("target", target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLBRElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLBRElement;
|
||||
|
||||
/**
|
||||
* An HTML 'BR' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLBRElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLBRElement
|
||||
{
|
||||
|
||||
protected DomHTMLBRElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getClear()
|
||||
{
|
||||
return getHTMLAttribute("clear");
|
||||
}
|
||||
|
||||
public void setClear(String clear)
|
||||
{
|
||||
setHTMLAttribute("clear", clear);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLBaseElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLBaseElement;
|
||||
|
||||
/**
|
||||
* An HTML 'BASE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLBaseElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLBaseElement
|
||||
{
|
||||
|
||||
protected DomHTMLBaseElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getHref()
|
||||
{
|
||||
return getHTMLAttribute("href");
|
||||
}
|
||||
|
||||
public void setHref(String href)
|
||||
{
|
||||
setHTMLAttribute("href", href);
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return getHTMLAttribute("target");
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHTMLAttribute("target", target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* DomHTMLBaseFontElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLBaseFontElement;
|
||||
|
||||
/**
|
||||
* An HTML 'BASEFONT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLBaseFontElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLBaseFontElement
|
||||
{
|
||||
|
||||
protected DomHTMLBaseFontElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
{
|
||||
return getHTMLAttribute("color");
|
||||
}
|
||||
|
||||
public void setColor(String color)
|
||||
{
|
||||
setHTMLAttribute("color", color);
|
||||
}
|
||||
|
||||
public String getFace()
|
||||
{
|
||||
return getHTMLAttribute("face");
|
||||
}
|
||||
|
||||
public void setFace(String face)
|
||||
{
|
||||
setHTMLAttribute("face", face);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return getIntHTMLAttribute("size");
|
||||
}
|
||||
|
||||
public void setSize(int size)
|
||||
{
|
||||
setIntHTMLAttribute("size", size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/* DomHTMLBodyElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLBodyElement;
|
||||
|
||||
/**
|
||||
* An HTML 'BODY' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLBodyElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLBodyElement
|
||||
{
|
||||
|
||||
protected DomHTMLBodyElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getALink()
|
||||
{
|
||||
return getHTMLAttribute("alink");
|
||||
}
|
||||
|
||||
public void setALink(String alink)
|
||||
{
|
||||
setHTMLAttribute("alink", alink);
|
||||
}
|
||||
|
||||
public String getBackground()
|
||||
{
|
||||
return getHTMLAttribute("background");
|
||||
}
|
||||
|
||||
public void setBackground(String background)
|
||||
{
|
||||
setHTMLAttribute("background", background);
|
||||
}
|
||||
|
||||
public String getBgColor()
|
||||
{
|
||||
return getHTMLAttribute("bgcolor");
|
||||
}
|
||||
|
||||
public void setBgColor(String bgcolor)
|
||||
{
|
||||
setHTMLAttribute("bgcolor", bgcolor);
|
||||
}
|
||||
|
||||
public String getLink()
|
||||
{
|
||||
return getHTMLAttribute("link");
|
||||
}
|
||||
|
||||
public void setLink(String link)
|
||||
{
|
||||
setHTMLAttribute("link", link);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return getHTMLAttribute("text");
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
setHTMLAttribute("text", text);
|
||||
}
|
||||
|
||||
public String getVLink()
|
||||
{
|
||||
return getHTMLAttribute("vlink");
|
||||
}
|
||||
|
||||
public void setVLink(String vlink)
|
||||
{
|
||||
setHTMLAttribute("vlink", vlink);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/* DomHTMLButtonElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.html2.HTMLButtonElement;
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
|
||||
/**
|
||||
* An HTML 'BUTTON' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLButtonElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLButtonElement
|
||||
{
|
||||
|
||||
protected DomHTMLButtonElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
setHTMLAttribute("value", value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/* DomHTMLCollection.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import gnu.xml.dom.DomElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLOptionsCollection;
|
||||
import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.NodeIterator;
|
||||
|
||||
/**
|
||||
* An HTML element collection.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class DomHTMLCollection
|
||||
implements HTMLCollection, HTMLOptionsCollection, NodeList, NodeFilter
|
||||
{
|
||||
|
||||
final DomHTMLDocument doc;
|
||||
final Node root;
|
||||
List nodeNames;
|
||||
List attributeNames;
|
||||
List results;
|
||||
|
||||
DomHTMLCollection(DomHTMLDocument doc, Node root)
|
||||
{
|
||||
this.doc = doc;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
// -- Node name and attribute filtering --
|
||||
|
||||
void addNodeName(String name)
|
||||
{
|
||||
if (nodeNames == null)
|
||||
{
|
||||
nodeNames = new LinkedList();
|
||||
}
|
||||
nodeNames.add(name);
|
||||
}
|
||||
|
||||
void addAttributeName(String name)
|
||||
{
|
||||
if (attributeNames == null)
|
||||
{
|
||||
attributeNames = new LinkedList();
|
||||
}
|
||||
attributeNames.add(name);
|
||||
}
|
||||
|
||||
public short acceptNode(Node n)
|
||||
{
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE)
|
||||
{
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
}
|
||||
String localName = n.getLocalName();
|
||||
if (localName == null)
|
||||
{
|
||||
localName = n.getNodeName();
|
||||
}
|
||||
if (nodeNames != null && !acceptName(localName))
|
||||
{
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
}
|
||||
if (attributeNames != null && !acceptAttributes(n.getAttributes()))
|
||||
{
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
}
|
||||
return NodeFilter.FILTER_ACCEPT;
|
||||
}
|
||||
|
||||
private boolean acceptName(String name)
|
||||
{
|
||||
for (Iterator i = nodeNames.iterator(); i.hasNext(); )
|
||||
{
|
||||
String nodeName = (String) i.next();
|
||||
if (nodeName.equalsIgnoreCase(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean acceptAttributes(NamedNodeMap attrs)
|
||||
{
|
||||
for (Iterator i = attributeNames.iterator(); i.hasNext(); )
|
||||
{
|
||||
String attributeName = (String) i.next();
|
||||
Node attr = getNamedItem(attrs, attributeName);
|
||||
if (attr != null)
|
||||
{
|
||||
// Check that attribute has a non-null value
|
||||
String nodeValue = attr.getNodeValue();
|
||||
if (nodeValue != null && nodeValue.length() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Case-insensitive version of getNamedItem.
|
||||
*/
|
||||
private Node getNamedItem(NamedNodeMap attrs, String name)
|
||||
{
|
||||
int len = attrs.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node attr = attrs.item(i);
|
||||
String attrName = attr.getLocalName();
|
||||
if (attrName == null)
|
||||
{
|
||||
attrName = attr.getNodeName();
|
||||
}
|
||||
if (name.equalsIgnoreCase(attrName))
|
||||
{
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// -- Perform query --
|
||||
|
||||
void evaluate()
|
||||
{
|
||||
NodeIterator i = doc.createNodeIterator(root, NodeFilter.SHOW_ELEMENT,
|
||||
this, true);
|
||||
results = new ArrayList();
|
||||
for (Node node = i.nextNode(); node != null; node = i.nextNode())
|
||||
{
|
||||
results.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
// -- HTMLCollection/NodeList interface --
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return results.size();
|
||||
}
|
||||
|
||||
public void setLength(int length)
|
||||
{
|
||||
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
|
||||
}
|
||||
|
||||
public Node item(int index)
|
||||
{
|
||||
return (Node) results.get(index);
|
||||
}
|
||||
|
||||
public Node namedItem(String name)
|
||||
{
|
||||
boolean xhtml = false; // FIXME detect XHTML document
|
||||
for (Iterator i = results.iterator(); i.hasNext(); )
|
||||
{
|
||||
Node node = (Node) i.next();
|
||||
NamedNodeMap attrs = node.getAttributes();
|
||||
Node attr = getNamedItem(attrs, "id");
|
||||
if (name.equals(attr.getTextContent()))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
if (!xhtml)
|
||||
{
|
||||
attr = getNamedItem(attrs, "name");
|
||||
if (name.equals(attr.getTextContent()))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLDListElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLDListElement;
|
||||
|
||||
/**
|
||||
* An HTML 'DL' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLDListElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLDListElement
|
||||
{
|
||||
|
||||
protected DomHTMLDListElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getCompact()
|
||||
{
|
||||
return getBooleanHTMLAttribute("compact");
|
||||
}
|
||||
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
setBooleanHTMLAttribute("compact", compact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLDirectoryElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLDirectoryElement;
|
||||
|
||||
/**
|
||||
* An HTML 'DIR' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLDirectoryElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLDirectoryElement
|
||||
{
|
||||
|
||||
protected DomHTMLDirectoryElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getCompact()
|
||||
{
|
||||
return getBooleanHTMLAttribute("compact");
|
||||
}
|
||||
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
setBooleanHTMLAttribute("compact", compact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLDivElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLDivElement;
|
||||
|
||||
/**
|
||||
* An HTML 'DIV' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLDivElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLDivElement
|
||||
{
|
||||
|
||||
protected DomHTMLDivElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
/* DomHTMLDocument.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDocument;
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLDocument;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
|
||||
/**
|
||||
* An HTML document.
|
||||
* This is the factory object used to create HTML elements.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLDocument
|
||||
extends DomDocument
|
||||
implements HTMLDocument
|
||||
{
|
||||
|
||||
private static final Class[] ELEMENT_PT = new Class[] {
|
||||
DomHTMLDocument.class,
|
||||
String.class,
|
||||
String.class
|
||||
};
|
||||
|
||||
private static Map ELEMENT_CLASSES;
|
||||
static
|
||||
{
|
||||
Map map = new HashMap();
|
||||
map.put("a", DomHTMLAnchorElement.class);
|
||||
map.put("applet", DomHTMLAppletElement.class);
|
||||
map.put("area", DomHTMLAreaElement.class);
|
||||
map.put("base", DomHTMLBaseElement.class);
|
||||
map.put("basefont", DomHTMLBaseFontElement.class);
|
||||
map.put("body", DomHTMLBodyElement.class);
|
||||
map.put("br", DomHTMLBRElement.class);
|
||||
map.put("button", DomHTMLButtonElement.class);
|
||||
map.put("dir", DomHTMLDirectoryElement.class);
|
||||
map.put("div", DomHTMLDivElement.class);
|
||||
map.put("dlist", DomHTMLDListElement.class);
|
||||
map.put("fieldset", DomHTMLFieldSetElement.class);
|
||||
map.put("font", DomHTMLFontElement.class);
|
||||
map.put("form", DomHTMLFormElement.class);
|
||||
map.put("frame", DomHTMLFrameElement.class);
|
||||
map.put("frameset", DomHTMLFrameSetElement.class);
|
||||
map.put("head", DomHTMLHeadElement.class);
|
||||
map.put("h1", DomHTMLHeadingElement.class);
|
||||
map.put("h2", DomHTMLHeadingElement.class);
|
||||
map.put("h3", DomHTMLHeadingElement.class);
|
||||
map.put("h4", DomHTMLHeadingElement.class);
|
||||
map.put("h5", DomHTMLHeadingElement.class);
|
||||
map.put("h6", DomHTMLHeadingElement.class);
|
||||
map.put("html", DomHTMLHtmlElement.class);
|
||||
map.put("iframe", DomHTMLIFrameElement.class);
|
||||
map.put("img", DomHTMLImageElement.class);
|
||||
map.put("input", DomHTMLInputElement.class);
|
||||
map.put("isindex", DomHTMLIsIndexElement.class);
|
||||
map.put("label", DomHTMLLabelElement.class);
|
||||
map.put("legend", DomHTMLLegendElement.class);
|
||||
map.put("li", DomHTMLLIElement.class);
|
||||
map.put("link", DomHTMLLinkElement.class);
|
||||
map.put("map", DomHTMLMapElement.class);
|
||||
map.put("menu", DomHTMLMenuElement.class);
|
||||
map.put("meta", DomHTMLMetaElement.class);
|
||||
map.put("ins", DomHTMLModElement.class);
|
||||
map.put("del", DomHTMLModElement.class);
|
||||
map.put("object", DomHTMLObjectElement.class);
|
||||
map.put("ol", DomHTMLOListElement.class);
|
||||
map.put("optgroup", DomHTMLOptGroupElement.class);
|
||||
map.put("option", DomHTMLOptionElement.class);
|
||||
map.put("p", DomHTMLParagraphElement.class);
|
||||
map.put("param", DomHTMLParamElement.class);
|
||||
map.put("pre", DomHTMLPreElement.class);
|
||||
map.put("q", DomHTMLQuoteElement.class);
|
||||
map.put("blockquote", DomHTMLQuoteElement.class);
|
||||
map.put("script", DomHTMLScriptElement.class);
|
||||
map.put("select", DomHTMLSelectElement.class);
|
||||
map.put("style", DomHTMLStyleElement.class);
|
||||
map.put("caption", DomHTMLTableCaptionElement.class);
|
||||
map.put("th", DomHTMLTableCellElement.class);
|
||||
map.put("td", DomHTMLTableCellElement.class);
|
||||
map.put("col", DomHTMLTableColElement.class);
|
||||
map.put("colgroup", DomHTMLTableColElement.class);
|
||||
map.put("table", DomHTMLTableElement.class);
|
||||
map.put("tr", DomHTMLTableRowElement.class);
|
||||
map.put("thead", DomHTMLTableSectionElement.class);
|
||||
map.put("tfoot", DomHTMLTableSectionElement.class);
|
||||
map.put("tbody", DomHTMLTableSectionElement.class);
|
||||
map.put("textarea", DomHTMLTextAreaElement.class);
|
||||
map.put("title", DomHTMLTitleElement.class);
|
||||
map.put("ul", DomHTMLUListElement.class);
|
||||
ELEMENT_CLASSES = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
private static Set HTML_NS_URIS;
|
||||
static
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add("http://www.w3.org/TR/html4/strict");
|
||||
set.add("http://www.w3.org/TR/html4/loose");
|
||||
set.add("http://www.w3.org/TR/html4/frameset");
|
||||
set.add("http://www.w3.org/1999/xhtml");
|
||||
set.add("http://www.w3.org/TR/xhtml1/strict");
|
||||
set.add("http://www.w3.org/TR/xhtml1/loose");
|
||||
set.add("http://www.w3.org/TR/xhtml1/frameset");
|
||||
HTML_NS_URIS = Collections.unmodifiableSet(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor.
|
||||
*/
|
||||
public DomHTMLDocument()
|
||||
{
|
||||
this(new DomHTMLImpl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* This is called by the DOMImplementation.
|
||||
*/
|
||||
public DomHTMLDocument(DomHTMLImpl impl)
|
||||
{
|
||||
super(impl);
|
||||
}
|
||||
|
||||
private Node getChildNodeByName(Node parent, String name)
|
||||
{
|
||||
for (Node ctx = parent.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
if (name.equalsIgnoreCase(ctx.getNodeName()))
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
Node html = getDocumentElement();
|
||||
if (html != null)
|
||||
{
|
||||
Node head = getChildNodeByName(html, "head");
|
||||
if (head != null)
|
||||
{
|
||||
Node title = getChildNodeByName(head, "title");
|
||||
if (title != null)
|
||||
{
|
||||
return title.getTextContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
Node html = getDocumentElement();
|
||||
if (html == null)
|
||||
{
|
||||
html = createElement("html");
|
||||
appendChild(html);
|
||||
}
|
||||
Node head = getChildNodeByName(html, "head");
|
||||
if (head == null)
|
||||
{
|
||||
head = createElement("head");
|
||||
Node first = html.getFirstChild();
|
||||
if (first != null)
|
||||
{
|
||||
html.insertBefore(first, head);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.appendChild(head);
|
||||
}
|
||||
}
|
||||
Node titleNode = getChildNodeByName(head, "title");
|
||||
if (titleNode == null)
|
||||
{
|
||||
titleNode = createElement("title");
|
||||
Node first = head.getFirstChild();
|
||||
if (first != null)
|
||||
{
|
||||
head.insertBefore(first, titleNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
head.appendChild(titleNode);
|
||||
}
|
||||
}
|
||||
titleNode.setTextContent(title);
|
||||
}
|
||||
|
||||
public String getReferrer()
|
||||
{
|
||||
// TODO getReferrer
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDomain()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = new URL(getDocumentURI());
|
||||
return url.getHost();
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getURL()
|
||||
{
|
||||
return getDocumentURI();
|
||||
}
|
||||
|
||||
public HTMLElement getBody()
|
||||
{
|
||||
Node html = getDocumentElement();
|
||||
if (html != null)
|
||||
{
|
||||
Node body = getChildNodeByName(html, "body");
|
||||
if (body == null)
|
||||
{
|
||||
body = getChildNodeByName(html, "frameset");
|
||||
}
|
||||
return (HTMLElement) body;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBody(HTMLElement body)
|
||||
{
|
||||
Node html = getDocumentElement();
|
||||
if (html == null)
|
||||
{
|
||||
html = createElement("html");
|
||||
appendChild(html);
|
||||
}
|
||||
Node ref = getBody();
|
||||
if (ref == null)
|
||||
{
|
||||
html.appendChild(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replaceChild(body, ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLCollection getImages()
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName("img");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLCollection getApplets()
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName("object");
|
||||
ret.addNodeName("applet");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLCollection getLinks()
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName("area");
|
||||
ret.addNodeName("a");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLCollection getForms()
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName("form");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLCollection getAnchors()
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName("a");
|
||||
ret.addAttributeName("name");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getCookie()
|
||||
{
|
||||
// TODO getCookie
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCookie(String cookie)
|
||||
{
|
||||
// TODO setCookie
|
||||
}
|
||||
|
||||
public void open()
|
||||
{
|
||||
// TODO open
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
// TODO close
|
||||
}
|
||||
|
||||
public void write(String text)
|
||||
{
|
||||
// TODO write
|
||||
}
|
||||
|
||||
public void writeln(String text)
|
||||
{
|
||||
// TODO write
|
||||
}
|
||||
|
||||
public NodeList getElementsByName(String name)
|
||||
{
|
||||
DomHTMLCollection ret = new DomHTMLCollection(this, this);
|
||||
ret.addNodeName(name);
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
// TODO xhtml: return only form controls (?)
|
||||
}
|
||||
|
||||
public Element createElement(String tagName)
|
||||
{
|
||||
return createElementNS(null, tagName);
|
||||
}
|
||||
|
||||
public Element createElementNS(String uri, String qName)
|
||||
{
|
||||
/* If a non-HTML element, use the default implementation. */
|
||||
if (uri != null && !HTML_NS_URIS.contains(uri))
|
||||
{
|
||||
return super.createElementNS(uri, qName);
|
||||
}
|
||||
String localName = qName.toLowerCase();
|
||||
int ci = qName.indexOf(':');
|
||||
if (ci != -1)
|
||||
{
|
||||
localName = qName.substring(ci + 1);
|
||||
}
|
||||
Class t = (Class) ELEMENT_CLASSES.get(localName);
|
||||
/* If a non-HTML element, use the default implementation. */
|
||||
if (t == null)
|
||||
{
|
||||
return super.createElementNS(uri, qName);
|
||||
}
|
||||
try
|
||||
{
|
||||
Constructor c = t.getDeclaredConstructor(ELEMENT_PT);
|
||||
Object[] args = new Object[] { this, uri, qName };
|
||||
return (Element) c.newInstance(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DOMException e2 = new DomDOMException(DOMException.TYPE_MISMATCH_ERR);
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
/* DomHTMLElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import gnu.xml.dom.DomElement;
|
||||
import gnu.xml.dom.DomEvent;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.events.UIEvent;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
|
||||
/**
|
||||
* Abstract implementation of an HTML element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public abstract class DomHTMLElement
|
||||
extends DomElement
|
||||
implements HTMLElement
|
||||
{
|
||||
|
||||
protected DomHTMLElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the specified attribute.
|
||||
* The attribute name is case insensitive.
|
||||
*/
|
||||
protected String getHTMLAttribute(String name)
|
||||
{
|
||||
if (hasAttributes())
|
||||
{
|
||||
NamedNodeMap attrs = getAttributes();
|
||||
int len = attrs.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node attr = attrs.item(i);
|
||||
String attrName = attr.getLocalName();
|
||||
if (attrName == null)
|
||||
{
|
||||
attrName = attr.getNodeName();
|
||||
}
|
||||
if (attrName.equalsIgnoreCase(name))
|
||||
{
|
||||
return attr.getNodeValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected int getIntHTMLAttribute(String name)
|
||||
{
|
||||
String value = getHTMLAttribute(name);
|
||||
if (value == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getBooleanHTMLAttribute(String name)
|
||||
{
|
||||
String value = getHTMLAttribute(name);
|
||||
return value != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the specified attribute.
|
||||
* The attribute name is case insensitive.
|
||||
*/
|
||||
protected void setHTMLAttribute(String name, String value)
|
||||
{
|
||||
Node attr;
|
||||
NamedNodeMap attrs = getAttributes();
|
||||
int len = attrs.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
attr = attrs.item(i);
|
||||
String attrName = attr.getLocalName();
|
||||
if (attrName == null)
|
||||
{
|
||||
attrName = attr.getNodeName();
|
||||
}
|
||||
if (attrName.equalsIgnoreCase(name))
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
attr.setNodeValue(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
attrs.removeNamedItem(attr.getNodeName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
// Create a new attribute
|
||||
DomHTMLDocument doc = (DomHTMLDocument) getOwnerDocument();
|
||||
// XXX namespace URI for attribute?
|
||||
attr = doc.createAttribute(name);
|
||||
attr.setNodeValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setIntHTMLAttribute(String name, int value)
|
||||
{
|
||||
setHTMLAttribute(name, Integer.toString(value));
|
||||
}
|
||||
|
||||
protected void setBooleanHTMLAttribute(String name, boolean value)
|
||||
{
|
||||
setHTMLAttribute(name, value ? name : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first parent element with the specified name.
|
||||
*/
|
||||
protected Node getParentElement(String name)
|
||||
{
|
||||
for (Node parent = getParentNode(); parent != null;
|
||||
parent = parent.getParentNode())
|
||||
{
|
||||
String parentName = parent.getLocalName();
|
||||
if (parentName == null)
|
||||
{
|
||||
parentName = parent.getNodeName();
|
||||
}
|
||||
if (name.equalsIgnoreCase(parentName))
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first child element with the specified name.
|
||||
*/
|
||||
protected Node getChildElement(String name)
|
||||
{
|
||||
for (Node child = getFirstChild(); child != null;
|
||||
child = child.getNextSibling())
|
||||
{
|
||||
String childName = child.getLocalName();
|
||||
if (childName == null)
|
||||
{
|
||||
childName = child.getLocalName();
|
||||
}
|
||||
if (name.equalsIgnoreCase(childName))
|
||||
{
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of this element among elements of the same name,
|
||||
* relative to its parent.
|
||||
*/
|
||||
protected int getIndex()
|
||||
{
|
||||
int index = 0;
|
||||
Node parent = getParentNode();
|
||||
if (parent != null)
|
||||
{
|
||||
for (Node ctx = parent.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
if (ctx == this)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
|
||||
protected void dispatchUIEvent(String name)
|
||||
{
|
||||
UIEvent event = new DomEvent.DomUIEvent(name);
|
||||
dispatchEvent(event);
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return getHTMLAttribute("id");
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
setHTMLAttribute("id", id);
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return getHTMLAttribute("title");
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
setHTMLAttribute("title", title);
|
||||
}
|
||||
|
||||
public String getLang()
|
||||
{
|
||||
return getHTMLAttribute("lang");
|
||||
}
|
||||
|
||||
public void setLang(String lang)
|
||||
{
|
||||
setHTMLAttribute("lang", lang);
|
||||
}
|
||||
|
||||
public String getDir()
|
||||
{
|
||||
return getHTMLAttribute("dir");
|
||||
}
|
||||
|
||||
public void setDir(String dir)
|
||||
{
|
||||
setHTMLAttribute("dir", dir);
|
||||
}
|
||||
|
||||
public String getClassName()
|
||||
{
|
||||
return getHTMLAttribute("class");
|
||||
}
|
||||
|
||||
public void setClassName(String className)
|
||||
{
|
||||
setHTMLAttribute("class", className);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* DomHTMLFieldSetElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFieldSetElement;
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
|
||||
/**
|
||||
* An HTML 'FIELDSET' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLFieldSetElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLFieldSetElement
|
||||
{
|
||||
|
||||
protected DomHTMLFieldSetElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* DomHTMLFontElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFontElement;
|
||||
|
||||
/**
|
||||
* An HTML 'FONT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLFontElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLFontElement
|
||||
{
|
||||
|
||||
protected DomHTMLFontElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
{
|
||||
return getHTMLAttribute("color");
|
||||
}
|
||||
|
||||
public void setColor(String color)
|
||||
{
|
||||
setHTMLAttribute("color", color);
|
||||
}
|
||||
|
||||
public String getFace()
|
||||
{
|
||||
return getHTMLAttribute("face");
|
||||
}
|
||||
|
||||
public void setFace(String face)
|
||||
{
|
||||
setHTMLAttribute("face", face);
|
||||
}
|
||||
|
||||
public String getSize()
|
||||
{
|
||||
return getHTMLAttribute("size");
|
||||
}
|
||||
|
||||
public void setSize(String size)
|
||||
{
|
||||
setHTMLAttribute("size", size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/* DomHTMLFormElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
|
||||
/**
|
||||
* An HTML 'FORM' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLFormElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLFormElement
|
||||
{
|
||||
|
||||
protected DomHTMLFormElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLCollection getElements()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("input");
|
||||
ret.addNodeName("button");
|
||||
ret.addNodeName("select");
|
||||
ret.addNodeName("textarea");
|
||||
ret.addNodeName("isindex");
|
||||
ret.addNodeName("label");
|
||||
ret.addNodeName("option");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return getElements().getLength();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getAcceptCharset()
|
||||
{
|
||||
return getHTMLAttribute("accept-charset");
|
||||
}
|
||||
|
||||
public void setAcceptCharset(String acceptCharset)
|
||||
{
|
||||
setHTMLAttribute("accept-charset", acceptCharset);
|
||||
}
|
||||
|
||||
public String getAction()
|
||||
{
|
||||
return getHTMLAttribute("action");
|
||||
}
|
||||
|
||||
public void setAction(String action)
|
||||
{
|
||||
setHTMLAttribute("action", action);
|
||||
}
|
||||
|
||||
public String getEnctype()
|
||||
{
|
||||
return getHTMLAttribute("enctype");
|
||||
}
|
||||
|
||||
public void setEnctype(String enctype)
|
||||
{
|
||||
setHTMLAttribute("enctype", enctype);
|
||||
}
|
||||
|
||||
public String getMethod()
|
||||
{
|
||||
return getHTMLAttribute("method");
|
||||
}
|
||||
|
||||
public void setMethod(String method)
|
||||
{
|
||||
setHTMLAttribute("method", method);
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return getHTMLAttribute("target");
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHTMLAttribute("target", target);
|
||||
}
|
||||
|
||||
public void submit()
|
||||
{
|
||||
dispatchUIEvent("submit");
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
dispatchUIEvent("reset");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/* DomHTMLFrameElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.html2.HTMLFrameElement;
|
||||
|
||||
/**
|
||||
* An HTML 'FRAME' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLFrameElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLFrameElement
|
||||
{
|
||||
|
||||
protected DomHTMLFrameElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getFrameBorder()
|
||||
{
|
||||
return getHTMLAttribute("frameborder");
|
||||
}
|
||||
|
||||
public void setFrameBorder(String frameBorder)
|
||||
{
|
||||
setHTMLAttribute("frameborder", frameBorder);
|
||||
}
|
||||
|
||||
public String getLongDesc()
|
||||
{
|
||||
return getHTMLAttribute("longdesc");
|
||||
}
|
||||
|
||||
public void setLongDesc(String longDesc)
|
||||
{
|
||||
setHTMLAttribute("longdesc", longDesc);
|
||||
}
|
||||
|
||||
public String getMarginHeight()
|
||||
{
|
||||
return getHTMLAttribute("marginheight");
|
||||
}
|
||||
|
||||
public void setMarginHeight(String marginHeight)
|
||||
{
|
||||
setHTMLAttribute("marginheight", marginHeight);
|
||||
}
|
||||
|
||||
public String getMarginWidth()
|
||||
{
|
||||
return getHTMLAttribute("marginwidth");
|
||||
}
|
||||
|
||||
public void setMarginWidth(String marginWidth)
|
||||
{
|
||||
setHTMLAttribute("marginwidth", marginWidth);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public boolean getNoResize()
|
||||
{
|
||||
return getBooleanHTMLAttribute("noresize");
|
||||
}
|
||||
|
||||
public void setNoResize(boolean noResize)
|
||||
{
|
||||
setBooleanHTMLAttribute("noresize", noResize);
|
||||
}
|
||||
|
||||
public String getScrolling()
|
||||
{
|
||||
return getHTMLAttribute("scrolling");
|
||||
}
|
||||
|
||||
public void setScrolling(String scrolling)
|
||||
{
|
||||
setHTMLAttribute("scrolling", scrolling);
|
||||
}
|
||||
|
||||
public String getSrc()
|
||||
{
|
||||
return getHTMLAttribute("src");
|
||||
}
|
||||
|
||||
public void setSrc(String src)
|
||||
{
|
||||
setHTMLAttribute("src", src);
|
||||
}
|
||||
|
||||
public Document getContentDocument()
|
||||
{
|
||||
// TODO getContentDocument
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLFrameSetElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFrameSetElement;
|
||||
|
||||
/**
|
||||
* An HTML 'FRAMESET' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLFrameSetElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLFrameSetElement
|
||||
{
|
||||
|
||||
protected DomHTMLFrameSetElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getCols()
|
||||
{
|
||||
return getHTMLAttribute("cols");
|
||||
}
|
||||
|
||||
public void setCols(String cols)
|
||||
{
|
||||
setHTMLAttribute("cols", cols);
|
||||
}
|
||||
|
||||
public String getRows()
|
||||
{
|
||||
return getHTMLAttribute("rows");
|
||||
}
|
||||
|
||||
public void setRows(String rows)
|
||||
{
|
||||
setHTMLAttribute("rows", rows);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/* DomHTMLHRElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLHRElement;
|
||||
|
||||
/**
|
||||
* An HTML 'HR' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLHRElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLHRElement
|
||||
{
|
||||
|
||||
protected DomHTMLHRElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public boolean getNoShade()
|
||||
{
|
||||
return getBooleanHTMLAttribute("noshade");
|
||||
}
|
||||
|
||||
public void setNoShade(boolean noShade)
|
||||
{
|
||||
setBooleanHTMLAttribute("noshade", noShade);
|
||||
}
|
||||
|
||||
public String getSize()
|
||||
{
|
||||
return getHTMLAttribute("size");
|
||||
}
|
||||
|
||||
public void setSize(String size)
|
||||
{
|
||||
setHTMLAttribute("size", size);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLHeadElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLHeadElement;
|
||||
|
||||
/**
|
||||
* An HTML 'HEAD' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLHeadElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLHeadElement
|
||||
{
|
||||
|
||||
protected DomHTMLHeadElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getProfile()
|
||||
{
|
||||
return getHTMLAttribute("profile");
|
||||
}
|
||||
|
||||
public void setProfile(String profile)
|
||||
{
|
||||
setHTMLAttribute("profile", profile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLHeadingElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLHeadingElement;
|
||||
|
||||
/**
|
||||
* An HTML 'H1', 'H2', 'H3', 'H4', 'H5', or 'H6' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLHeadingElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLHeadingElement
|
||||
{
|
||||
|
||||
protected DomHTMLHeadingElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLHtmlElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLHtmlElement;
|
||||
|
||||
/**
|
||||
* An HTML 'HTML' top-level element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLHtmlElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLHtmlElement
|
||||
{
|
||||
|
||||
protected DomHTMLHtmlElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return getHTMLAttribute("version");
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
setHTMLAttribute("version", version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/* DomHTMLIFrameElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.html2.HTMLIFrameElement;
|
||||
|
||||
/**
|
||||
* An HTML 'IFRAME' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLIFrameElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLIFrameElement
|
||||
{
|
||||
|
||||
protected DomHTMLIFrameElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getFrameBorder()
|
||||
{
|
||||
return getHTMLAttribute("frameborder");
|
||||
}
|
||||
|
||||
public void setFrameBorder(String frameBorder)
|
||||
{
|
||||
setHTMLAttribute("frameborder", frameBorder);
|
||||
}
|
||||
|
||||
public String getHeight()
|
||||
{
|
||||
return getHTMLAttribute("height");
|
||||
}
|
||||
|
||||
public void setHeight(String height)
|
||||
{
|
||||
setHTMLAttribute("height", height);
|
||||
}
|
||||
|
||||
public String getLongDesc()
|
||||
{
|
||||
return getHTMLAttribute("longdesc");
|
||||
}
|
||||
|
||||
public void setLongDesc(String longDesc)
|
||||
{
|
||||
setHTMLAttribute("longdesc", longDesc);
|
||||
}
|
||||
|
||||
public String getMarginHeight()
|
||||
{
|
||||
return getHTMLAttribute("marginheight");
|
||||
}
|
||||
|
||||
public void setMarginHeight(String marginHeight)
|
||||
{
|
||||
setHTMLAttribute("marginheight", marginHeight);
|
||||
}
|
||||
|
||||
public String getMarginWidth()
|
||||
{
|
||||
return getHTMLAttribute("marginwidth");
|
||||
}
|
||||
|
||||
public void setMarginWidth(String marginWidth)
|
||||
{
|
||||
setHTMLAttribute("marginwidth", marginWidth);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getScrolling()
|
||||
{
|
||||
return getHTMLAttribute("scrolling");
|
||||
}
|
||||
|
||||
public void setScrolling(String scrolling)
|
||||
{
|
||||
setHTMLAttribute("scrolling", scrolling);
|
||||
}
|
||||
|
||||
public String getSrc()
|
||||
{
|
||||
return getHTMLAttribute("src");
|
||||
}
|
||||
|
||||
public void setSrc(String src)
|
||||
{
|
||||
setHTMLAttribute("src", src);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
public Document getContentDocument()
|
||||
{
|
||||
// TODO getContentDocument
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/* DomHTMLImageElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLImageElement;
|
||||
|
||||
/**
|
||||
* An HTML 'IMG' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLImageElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLImageElement
|
||||
{
|
||||
|
||||
protected DomHTMLImageElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getAlt()
|
||||
{
|
||||
return getHTMLAttribute("alt");
|
||||
}
|
||||
|
||||
public void setAlt(String alt)
|
||||
{
|
||||
setHTMLAttribute("alt", alt);
|
||||
}
|
||||
|
||||
public String getBorder()
|
||||
{
|
||||
return getHTMLAttribute("border");
|
||||
}
|
||||
|
||||
public void setBorder(String border)
|
||||
{
|
||||
setHTMLAttribute("border", border);
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return getIntHTMLAttribute("height");
|
||||
}
|
||||
|
||||
public void setHeight(int height)
|
||||
{
|
||||
setIntHTMLAttribute("height", height);
|
||||
}
|
||||
|
||||
public int getHspace()
|
||||
{
|
||||
return getIntHTMLAttribute("hspace");
|
||||
}
|
||||
|
||||
public void setHspace(int hspace)
|
||||
{
|
||||
setIntHTMLAttribute("hspace", hspace);
|
||||
}
|
||||
|
||||
public boolean getIsMap()
|
||||
{
|
||||
return getBooleanHTMLAttribute("ismap");
|
||||
}
|
||||
|
||||
public void setIsMap(boolean isMap)
|
||||
{
|
||||
setBooleanHTMLAttribute("ismap", isMap);
|
||||
}
|
||||
|
||||
public String getLongDesc()
|
||||
{
|
||||
return getHTMLAttribute("longdesc");
|
||||
}
|
||||
|
||||
public void setLongDesc(String longDesc)
|
||||
{
|
||||
setHTMLAttribute("longdesc", longDesc);
|
||||
}
|
||||
|
||||
public String getSrc()
|
||||
{
|
||||
return getHTMLAttribute("src");
|
||||
}
|
||||
|
||||
public void setSrc(String src)
|
||||
{
|
||||
setHTMLAttribute("src", src);
|
||||
}
|
||||
|
||||
public String getUseMap()
|
||||
{
|
||||
return getHTMLAttribute("usemap");
|
||||
}
|
||||
|
||||
public void setUseMap(String useMap)
|
||||
{
|
||||
setHTMLAttribute("usemap", useMap);
|
||||
}
|
||||
|
||||
public int getVspace()
|
||||
{
|
||||
return getIntHTMLAttribute("vspace");
|
||||
}
|
||||
|
||||
public void setVspace(int vspace)
|
||||
{
|
||||
setIntHTMLAttribute("vspace", vspace);
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return getIntHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
setIntHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/* DomHTMLImpl.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomImpl;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* Specialised DOMImplementation for creating HTML documents.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLImpl
|
||||
extends DomImpl
|
||||
{
|
||||
|
||||
protected Document createDocument()
|
||||
{
|
||||
return new DomHTMLDocument(this);
|
||||
}
|
||||
|
||||
public Object getFeature(String feature, String version)
|
||||
{
|
||||
if (hasFeature(feature, version))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/* DomHTMLInputElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLInputElement;
|
||||
|
||||
/**
|
||||
* An HTML 'INPUT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLInputElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLInputElement
|
||||
{
|
||||
|
||||
protected String value;
|
||||
protected Boolean checked;
|
||||
|
||||
protected DomHTMLInputElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue)
|
||||
{
|
||||
setHTMLAttribute("value", defaultValue);
|
||||
}
|
||||
|
||||
public boolean getDefaultChecked()
|
||||
{
|
||||
return getBooleanHTMLAttribute("checked");
|
||||
}
|
||||
|
||||
public void setDefaultChecked(boolean defaultChecked)
|
||||
{
|
||||
setBooleanHTMLAttribute("checked", defaultChecked);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getAccept()
|
||||
{
|
||||
return getHTMLAttribute("accept");
|
||||
}
|
||||
|
||||
public void setAccept(String accept)
|
||||
{
|
||||
setHTMLAttribute("accept", accept);
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getAlt()
|
||||
{
|
||||
return getHTMLAttribute("alt");
|
||||
}
|
||||
|
||||
public void setAlt(String alt)
|
||||
{
|
||||
setHTMLAttribute("alt", alt);
|
||||
}
|
||||
|
||||
public boolean getChecked()
|
||||
{
|
||||
if (checked == null)
|
||||
{
|
||||
checked = Boolean.valueOf(getDefaultChecked());
|
||||
}
|
||||
return checked.booleanValue();
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked)
|
||||
{
|
||||
this.checked = Boolean.valueOf(checked);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public int getMaxLength()
|
||||
{
|
||||
return getIntHTMLAttribute("maxLength");
|
||||
}
|
||||
|
||||
public void setMaxLength(int maxLength)
|
||||
{
|
||||
setIntHTMLAttribute("maxLength", maxLength);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public boolean getReadOnly()
|
||||
{
|
||||
return getBooleanHTMLAttribute("readonly");
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly)
|
||||
{
|
||||
setBooleanHTMLAttribute("readonly", readOnly);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return getIntHTMLAttribute("size");
|
||||
}
|
||||
|
||||
public void setSize(int size)
|
||||
{
|
||||
setIntHTMLAttribute("size", size);
|
||||
}
|
||||
|
||||
public String getSrc()
|
||||
{
|
||||
return getHTMLAttribute("src");
|
||||
}
|
||||
|
||||
public void setSrc(String src)
|
||||
{
|
||||
setHTMLAttribute("src", src);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
public String getUseMap()
|
||||
{
|
||||
return getHTMLAttribute("usemap");
|
||||
}
|
||||
|
||||
public void setUseMap(String useMap)
|
||||
{
|
||||
setHTMLAttribute("usemap", useMap);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = getDefaultValue();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void blur()
|
||||
{
|
||||
dispatchUIEvent("blur");
|
||||
}
|
||||
|
||||
public void focus()
|
||||
{
|
||||
dispatchUIEvent("focus");
|
||||
}
|
||||
|
||||
public void select()
|
||||
{
|
||||
dispatchUIEvent("select");
|
||||
}
|
||||
|
||||
public void click()
|
||||
{
|
||||
dispatchUIEvent("click");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/* DomHTMLIsIndexElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLIsIndexElement;
|
||||
|
||||
/**
|
||||
* An HTML 'ISINDEX' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLIsIndexElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLIsIndexElement
|
||||
{
|
||||
|
||||
protected DomHTMLIsIndexElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getPrompt()
|
||||
{
|
||||
return getHTMLAttribute("prompt");
|
||||
}
|
||||
|
||||
public void setPrompt(String prompt)
|
||||
{
|
||||
setHTMLAttribute("prompt", prompt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLLIElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLLIElement;
|
||||
|
||||
/**
|
||||
* An HTML 'LI' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLLIElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLLIElement
|
||||
{
|
||||
|
||||
protected DomHTMLLIElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return getIntHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
setIntHTMLAttribute("value", value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* DomHTMLLabelElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLLabelElement;
|
||||
|
||||
/**
|
||||
* An HTML 'LABEL' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLLabelElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLLabelElement
|
||||
{
|
||||
|
||||
protected DomHTMLLabelElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public String getHtmlFor()
|
||||
{
|
||||
return getHTMLAttribute("for");
|
||||
}
|
||||
|
||||
public void setHtmlFor(String htmlFor)
|
||||
{
|
||||
setHTMLAttribute("for", htmlFor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* DomHTMLLegendElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLLegendElement;
|
||||
|
||||
/**
|
||||
* An HTML 'LEGEND' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLLegendElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLLegendElement
|
||||
{
|
||||
|
||||
protected DomHTMLLegendElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/* DomHTMLLinkElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLLinkElement;
|
||||
|
||||
/**
|
||||
* An HTML 'LINK' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLLinkElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLLinkElement
|
||||
{
|
||||
|
||||
protected DomHTMLLinkElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getCharset()
|
||||
{
|
||||
return getHTMLAttribute("charset");
|
||||
}
|
||||
|
||||
public void setCharset(String charset)
|
||||
{
|
||||
setHTMLAttribute("charset", charset);
|
||||
}
|
||||
|
||||
public String getHref()
|
||||
{
|
||||
return getHTMLAttribute("href");
|
||||
}
|
||||
|
||||
public void setHref(String href)
|
||||
{
|
||||
setHTMLAttribute("href", href);
|
||||
}
|
||||
|
||||
public String getHreflang()
|
||||
{
|
||||
return getHTMLAttribute("hreflang");
|
||||
}
|
||||
|
||||
public void setHreflang(String hreflang)
|
||||
{
|
||||
setHTMLAttribute("hreflang", hreflang);
|
||||
}
|
||||
|
||||
public String getMedia()
|
||||
{
|
||||
return getHTMLAttribute("media");
|
||||
}
|
||||
|
||||
public void setMedia(String media)
|
||||
{
|
||||
setHTMLAttribute("media", media);
|
||||
}
|
||||
|
||||
public String getRel()
|
||||
{
|
||||
return getHTMLAttribute("rel");
|
||||
}
|
||||
|
||||
public void setRel(String rel)
|
||||
{
|
||||
setHTMLAttribute("rel", rel);
|
||||
}
|
||||
|
||||
public String getRev()
|
||||
{
|
||||
return getHTMLAttribute("rev");
|
||||
}
|
||||
|
||||
public void setRev(String rev)
|
||||
{
|
||||
setHTMLAttribute("rev", rev);
|
||||
}
|
||||
|
||||
public String getTarget()
|
||||
{
|
||||
return getHTMLAttribute("target");
|
||||
}
|
||||
|
||||
public void setTarget(String target)
|
||||
{
|
||||
setHTMLAttribute("target", target);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLMapElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLMapElement;
|
||||
|
||||
/**
|
||||
* An HTML 'MAP' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLMapElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLMapElement
|
||||
{
|
||||
|
||||
protected DomHTMLMapElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLCollection getAreas()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("area");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLMenuElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLMenuElement;
|
||||
|
||||
/**
|
||||
* An HTML 'MENU' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLMenuElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLMenuElement
|
||||
{
|
||||
|
||||
protected DomHTMLMenuElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getCompact()
|
||||
{
|
||||
return getBooleanHTMLAttribute("compact");
|
||||
}
|
||||
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
setBooleanHTMLAttribute("compact", compact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/* DomHTMLMetaElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLMetaElement;
|
||||
|
||||
/**
|
||||
* An HTML 'META' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLMetaElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLMetaElement
|
||||
{
|
||||
|
||||
protected DomHTMLMetaElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return getHTMLAttribute("content");
|
||||
}
|
||||
|
||||
public void setContent(String content)
|
||||
{
|
||||
setHTMLAttribute("content", content);
|
||||
}
|
||||
|
||||
public String getHttpEquiv()
|
||||
{
|
||||
return getHTMLAttribute("http-equiv");
|
||||
}
|
||||
|
||||
public void setHttpEquiv(String httpEquiv)
|
||||
{
|
||||
setHTMLAttribute("http-equiv", httpEquiv);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getScheme()
|
||||
{
|
||||
return getHTMLAttribute("scheme");
|
||||
}
|
||||
|
||||
public void setScheme(String scheme)
|
||||
{
|
||||
setHTMLAttribute("scheme", scheme);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLModElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLModElement;
|
||||
|
||||
/**
|
||||
* An HTML 'INS' or 'DEL' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLModElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLModElement
|
||||
{
|
||||
|
||||
protected DomHTMLModElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getCite()
|
||||
{
|
||||
return getHTMLAttribute("cite");
|
||||
}
|
||||
|
||||
public void setCite(String cite)
|
||||
{
|
||||
setHTMLAttribute("cite", cite);
|
||||
}
|
||||
|
||||
public String getDateTime()
|
||||
{
|
||||
return getHTMLAttribute("datetime");
|
||||
}
|
||||
|
||||
public void setDateTime(String dateTime)
|
||||
{
|
||||
setHTMLAttribute("datetime", dateTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* DomHTMLOListElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLOListElement;
|
||||
|
||||
/**
|
||||
* An HTML 'OL' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLOListElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLOListElement
|
||||
{
|
||||
|
||||
protected DomHTMLOListElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getCompact()
|
||||
{
|
||||
return getBooleanHTMLAttribute("compact");
|
||||
}
|
||||
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
setBooleanHTMLAttribute("compact", compact);
|
||||
}
|
||||
|
||||
public int getStart()
|
||||
{
|
||||
return getIntHTMLAttribute("start");
|
||||
}
|
||||
|
||||
public void setStart(int start)
|
||||
{
|
||||
setIntHTMLAttribute("start", start);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
/* DomHTMLObjectElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLObjectElement;
|
||||
|
||||
/**
|
||||
* An HTML 'OBJECT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLObjectElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLObjectElement
|
||||
{
|
||||
|
||||
protected DomHTMLObjectElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return getHTMLAttribute("code");
|
||||
}
|
||||
|
||||
public void setCode(String code)
|
||||
{
|
||||
setHTMLAttribute("code", code);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getArchive()
|
||||
{
|
||||
return getHTMLAttribute("archive");
|
||||
}
|
||||
|
||||
public void setArchive(String archive)
|
||||
{
|
||||
setHTMLAttribute("archive", archive);
|
||||
}
|
||||
|
||||
public String getBorder()
|
||||
{
|
||||
return getHTMLAttribute("border");
|
||||
}
|
||||
|
||||
public void setBorder(String border)
|
||||
{
|
||||
setHTMLAttribute("border", border);
|
||||
}
|
||||
|
||||
public String getCodeBase()
|
||||
{
|
||||
return getHTMLAttribute("codebase");
|
||||
}
|
||||
|
||||
public void setCodeBase(String codeBase)
|
||||
{
|
||||
setHTMLAttribute("codebase", codeBase);
|
||||
}
|
||||
|
||||
public String getCodeType()
|
||||
{
|
||||
return getHTMLAttribute("codetype");
|
||||
}
|
||||
|
||||
public void setCodeType(String codeType)
|
||||
{
|
||||
setHTMLAttribute("codetype", codeType);
|
||||
}
|
||||
|
||||
public String getData()
|
||||
{
|
||||
return getHTMLAttribute("data");
|
||||
}
|
||||
|
||||
public void setData(String data)
|
||||
{
|
||||
setHTMLAttribute("data", data);
|
||||
}
|
||||
|
||||
public boolean getDeclare()
|
||||
{
|
||||
return getBooleanHTMLAttribute("declare");
|
||||
}
|
||||
|
||||
public void setDeclare(boolean declare)
|
||||
{
|
||||
setBooleanHTMLAttribute("declare", declare);
|
||||
}
|
||||
|
||||
public String getHeight()
|
||||
{
|
||||
return getHTMLAttribute("height");
|
||||
}
|
||||
|
||||
public void setHeight(String height)
|
||||
{
|
||||
setHTMLAttribute("height", height);
|
||||
}
|
||||
|
||||
public int getHspace()
|
||||
{
|
||||
return getIntHTMLAttribute("hspace");
|
||||
}
|
||||
|
||||
public void setHspace(int hspace)
|
||||
{
|
||||
setIntHTMLAttribute("hspace", hspace);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getStandby()
|
||||
{
|
||||
return getHTMLAttribute("standby");
|
||||
}
|
||||
|
||||
public void setStandby(String standby)
|
||||
{
|
||||
setHTMLAttribute("standby", standby);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
public String getUseMap()
|
||||
{
|
||||
return getHTMLAttribute("usemap");
|
||||
}
|
||||
|
||||
public void setUseMap(String useMap)
|
||||
{
|
||||
setHTMLAttribute("usemap", useMap);
|
||||
}
|
||||
|
||||
public int getVspace()
|
||||
{
|
||||
return getIntHTMLAttribute("vspace");
|
||||
}
|
||||
|
||||
public void setVspace(int vspace)
|
||||
{
|
||||
setIntHTMLAttribute("vspace", vspace);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
public Document getContentDocument()
|
||||
{
|
||||
// TODO getContentDocument
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLOptGroupElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLOptGroupElement;
|
||||
|
||||
/**
|
||||
* An HTML 'OPTGROUP' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLOptGroupElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLOptGroupElement
|
||||
{
|
||||
|
||||
protected DomHTMLOptGroupElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return getHTMLAttribute("label");
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
setHTMLAttribute("label", label);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/* DomHTMLOptionElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLOptionElement;
|
||||
|
||||
/**
|
||||
* An HTML 'OPTION' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLOptionElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLOptionElement
|
||||
{
|
||||
|
||||
protected Boolean selected;
|
||||
|
||||
protected DomHTMLOptionElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public boolean getDefaultSelected()
|
||||
{
|
||||
return getBooleanHTMLAttribute("selected");
|
||||
}
|
||||
|
||||
public void setDefaultSelected(boolean defaultSelected)
|
||||
{
|
||||
setBooleanHTMLAttribute("selected", defaultSelected);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return getTextContent();
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return super.getIndex();
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return getHTMLAttribute("label");
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
setHTMLAttribute("label", label);
|
||||
}
|
||||
|
||||
public boolean getSelected()
|
||||
{
|
||||
if (selected == null)
|
||||
{
|
||||
selected = Boolean.valueOf(getDefaultSelected());
|
||||
}
|
||||
return selected.booleanValue();
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected)
|
||||
{
|
||||
this.selected = Boolean.valueOf(selected);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
setHTMLAttribute("value", value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLParagraphElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLParagraphElement;
|
||||
|
||||
/**
|
||||
* An HTML 'P' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLParagraphElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLParagraphElement
|
||||
{
|
||||
|
||||
protected DomHTMLParagraphElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/* DomHTMLParamElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLParamElement;
|
||||
|
||||
/**
|
||||
* An HTML 'PARAM' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLParamElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLParamElement
|
||||
{
|
||||
|
||||
protected DomHTMLParamElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
setHTMLAttribute("value", value);
|
||||
}
|
||||
|
||||
public String getValueType()
|
||||
{
|
||||
return getHTMLAttribute("valuetype");
|
||||
}
|
||||
|
||||
public void setValueType(String valueType)
|
||||
{
|
||||
setHTMLAttribute("valuetype", valueType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/* DomHTMLParser.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.javax.swing.text.html.parser.support.Parser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.parser.DTD;
|
||||
import javax.swing.text.html.parser.TagElement;
|
||||
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.html2.HTMLDocument;
|
||||
|
||||
/**
|
||||
* This parser reads HTML from the given stream and stores into
|
||||
* {@link HTMLDocument}. The HTML tag becomes the {@link Node}.
|
||||
* The tag attributes become the node attributes. The text inside
|
||||
* HTML tag is inserted as one or several text nodes. The nested
|
||||
* HTML tags are inserted as child nodes.
|
||||
*
|
||||
* If the strict tree structure, closing the tag means closing all
|
||||
* nested tags. To work around this, this parser closes the nested
|
||||
* tags and immediately reopens them after the closed tag.
|
||||
* In this way, <code><b><i>c</b>d</code>
|
||||
* is parsed as <code><b><i>c</i></b><i>d</code> .
|
||||
*
|
||||
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
|
||||
*/
|
||||
public class DomHTMLParser
|
||||
extends gnu.javax.swing.text.html.parser.support.Parser
|
||||
{
|
||||
/**
|
||||
* The target where HTML document will be inserted.
|
||||
*/
|
||||
protected DomHTMLDocument document;
|
||||
|
||||
/**
|
||||
* The subsequently created new nodes will be inserted as the
|
||||
* childs of this cursor.
|
||||
*/
|
||||
protected Node cursor;
|
||||
|
||||
/**
|
||||
* Create parser using the given DTD.
|
||||
*
|
||||
* @param dtd the DTD (for example,
|
||||
* {@link gnu.javax.swing.text.html.parser.HTML_401F}).
|
||||
*/
|
||||
public DomHTMLParser(DTD dtd)
|
||||
{
|
||||
super(dtd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse SGML insertion ( <! ... > ).
|
||||
* Currently just treats it as comment.
|
||||
*/
|
||||
public boolean parseMarkupDeclarations(StringBuffer strBuff)
|
||||
throws java.io.IOException
|
||||
{
|
||||
Node c = document.createComment(strBuff.toString());
|
||||
cursor.appendChild(c);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the document, present in the given stream, and
|
||||
* return the corresponding {@link HTMLDocument}.
|
||||
*
|
||||
* @param input a stream to read from.
|
||||
* @return a document, reflecting the structure of the provided HTML
|
||||
* text.
|
||||
*
|
||||
* @throws IOException if the reader throws one.
|
||||
*/
|
||||
public HTMLDocument parseDocument(Reader input)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
document = new DomHTMLDocument();
|
||||
|
||||
cursor = document;
|
||||
|
||||
parse(input);
|
||||
|
||||
DomHTMLDocument h = document;
|
||||
document = null;
|
||||
return h;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw new IOException("Exception: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new node.
|
||||
* @param name the name of node, case insensitive.
|
||||
* @return the created node.
|
||||
*/
|
||||
protected Node createNode(String name)
|
||||
{
|
||||
Node new_node = document.createElement(name.toLowerCase());
|
||||
AttributeSet hatts = getAttributes();
|
||||
NamedNodeMap natts = new_node.getAttributes();
|
||||
|
||||
Enumeration enumeration = hatts.getAttributeNames();
|
||||
Object key;
|
||||
Node attribute;
|
||||
|
||||
while (hatts != null)
|
||||
{
|
||||
while (enumeration.hasMoreElements())
|
||||
{
|
||||
key = enumeration.nextElement();
|
||||
attribute = document.createAttribute(key.toString());
|
||||
attribute.setNodeValue(hatts.getAttribute(key).toString());
|
||||
natts.setNamedItem(attribute);
|
||||
}
|
||||
|
||||
// The default values are stored in a parent node.
|
||||
hatts = hatts.getResolveParent();
|
||||
}
|
||||
|
||||
return new_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle comment by inserting the comment node.
|
||||
* @param text the comment text.
|
||||
*/
|
||||
protected void handleComment(char[] text)
|
||||
{
|
||||
Node c = document.createComment(new String(text));
|
||||
cursor.appendChild(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the tag with no content.
|
||||
* @param tag the tag to handle.
|
||||
*/
|
||||
protected void handleEmptyTag(TagElement tag)
|
||||
{
|
||||
String name = tag.getHTMLTag().toString();
|
||||
|
||||
if (name.equalsIgnoreCase("#pcdata"))
|
||||
return;
|
||||
|
||||
Node c = createNode(name);
|
||||
cursor.appendChild(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the given tag. Close and reopen all nested tags.
|
||||
* @param tag the tag to close.
|
||||
*/
|
||||
protected void handleEndTag(TagElement tag)
|
||||
{
|
||||
String name = tag.getHTMLTag().toString();
|
||||
String nname = cursor.getNodeName();
|
||||
|
||||
// Closing the current tag.
|
||||
if (nname != null && nname.equalsIgnoreCase(name))
|
||||
{
|
||||
cursor = cursor.getParentNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Node nCursor = cursor.getParentNode();
|
||||
|
||||
// Remember the opened nodes.
|
||||
LinkedList open = new LinkedList();
|
||||
Node close = cursor;
|
||||
while (close != null && !close.getNodeName().equalsIgnoreCase(name))
|
||||
{
|
||||
if (close != document)
|
||||
open.addFirst(close);
|
||||
close = close.getParentNode();
|
||||
}
|
||||
|
||||
if (close == null)
|
||||
cursor = document;
|
||||
else
|
||||
cursor = close.getParentNode();
|
||||
|
||||
// Insert the copies of the opened nodes.
|
||||
Iterator iter = open.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Node item = (Node) iter.next();
|
||||
Node copy = item.cloneNode(true);
|
||||
cursor.appendChild(copy);
|
||||
cursor = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the start tag by inserting the HTML element.
|
||||
* @param tag the tag to handle.
|
||||
*/
|
||||
protected void handleStartTag(TagElement tag)
|
||||
{
|
||||
HTML.Tag h = tag.getHTMLTag();
|
||||
Node c = createNode(h.toString());
|
||||
cursor.appendChild(c);
|
||||
cursor = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle text by inserting the text node.
|
||||
* @param text the text to insert.
|
||||
*/
|
||||
protected void handleText(char[] text)
|
||||
{
|
||||
Node c = document.createTextNode(text, 0, text.length);
|
||||
cursor.appendChild(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLPreElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLPreElement;
|
||||
|
||||
/**
|
||||
* An HTML 'PRE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLPreElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLPreElement
|
||||
{
|
||||
|
||||
protected DomHTMLPreElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return getIntHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
setIntHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLQuoteElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLQuoteElement;
|
||||
|
||||
/**
|
||||
* An HTML 'Q' or 'BLOCKQUOTE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLQuoteElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLQuoteElement
|
||||
{
|
||||
|
||||
protected DomHTMLQuoteElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getCite()
|
||||
{
|
||||
return getHTMLAttribute("cite");
|
||||
}
|
||||
|
||||
public void setCite(String cite)
|
||||
{
|
||||
setHTMLAttribute("cite", cite);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/* DomHTMLScriptElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLScriptElement;
|
||||
|
||||
/**
|
||||
* An HTML 'SCRIPT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLScriptElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLScriptElement
|
||||
{
|
||||
|
||||
protected DomHTMLScriptElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return getTextContent();
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
setTextContent(text);
|
||||
}
|
||||
|
||||
public String getHtmlFor()
|
||||
{
|
||||
return getHTMLAttribute("for");
|
||||
}
|
||||
|
||||
public void setHtmlFor(String htmlFor)
|
||||
{
|
||||
setHTMLAttribute("for", htmlFor);
|
||||
}
|
||||
|
||||
public String getEvent()
|
||||
{
|
||||
return getHTMLAttribute("event");
|
||||
}
|
||||
|
||||
public void setEvent(String event)
|
||||
{
|
||||
setHTMLAttribute("event", event);
|
||||
}
|
||||
|
||||
public String getCharset()
|
||||
{
|
||||
return getHTMLAttribute("charset");
|
||||
}
|
||||
|
||||
public void setCharset(String charset)
|
||||
{
|
||||
setHTMLAttribute("charset", charset);
|
||||
}
|
||||
|
||||
public boolean getDefer()
|
||||
{
|
||||
return getBooleanHTMLAttribute("defer");
|
||||
}
|
||||
|
||||
public void setDefer(boolean defer)
|
||||
{
|
||||
setBooleanHTMLAttribute("defer", defer);
|
||||
}
|
||||
|
||||
public String getSrc()
|
||||
{
|
||||
return getHTMLAttribute("src");
|
||||
}
|
||||
|
||||
public void setSrc(String src)
|
||||
{
|
||||
setHTMLAttribute("src", src);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/* DomHTMLSelectElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLOptionElement;
|
||||
import org.w3c.dom.html2.HTMLOptionsCollection;
|
||||
import org.w3c.dom.html2.HTMLSelectElement;
|
||||
|
||||
/**
|
||||
* An HTML 'SELECT' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLSelectElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLSelectElement
|
||||
{
|
||||
|
||||
protected DomHTMLSelectElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public int getSelectedIndex()
|
||||
{
|
||||
HTMLOptionsCollection options = getOptions();
|
||||
int len = options.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
HTMLOptionElement option = (HTMLOptionElement) options.item(i);
|
||||
if (option.getSelected())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setSelectedIndex(int selectedIndex)
|
||||
{
|
||||
HTMLOptionsCollection options = getOptions();
|
||||
int len = options.getLength();
|
||||
if (selectedIndex < 0 || selectedIndex >= len)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
HTMLOptionElement option = (HTMLOptionElement) options.item(i);
|
||||
option.setSelected(i == selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
setHTMLAttribute("value", value);
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return getIntHTMLAttribute("length");
|
||||
}
|
||||
|
||||
public void setLength(int length)
|
||||
{
|
||||
setIntHTMLAttribute("length", length);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public HTMLOptionsCollection getOptions()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("option");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public boolean getMultiple()
|
||||
{
|
||||
return getBooleanHTMLAttribute("multiple");
|
||||
}
|
||||
|
||||
public void setMultiple(boolean multiple)
|
||||
{
|
||||
setBooleanHTMLAttribute("multiple", multiple);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return getIntHTMLAttribute("size");
|
||||
}
|
||||
|
||||
public void setSize(int size)
|
||||
{
|
||||
setIntHTMLAttribute("size", size);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public void add(HTMLElement element, HTMLElement before)
|
||||
{
|
||||
insertBefore(before, element);
|
||||
}
|
||||
|
||||
public void remove(int index)
|
||||
{
|
||||
HTMLOptionsCollection options = getOptions();
|
||||
int len = options.getLength();
|
||||
if (index < 0 || index >= len)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
HTMLOptionElement option = (HTMLOptionElement) options.item(index);
|
||||
option.getParentNode().removeChild(option);
|
||||
}
|
||||
|
||||
public void blur()
|
||||
{
|
||||
dispatchUIEvent("blur");
|
||||
}
|
||||
|
||||
public void focus()
|
||||
{
|
||||
dispatchUIEvent("focus");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* DomHTMLStyleElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLStyleElement;
|
||||
|
||||
/**
|
||||
* An HTML 'STYLE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLStyleElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLStyleElement
|
||||
{
|
||||
|
||||
protected DomHTMLStyleElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getMedia()
|
||||
{
|
||||
return getHTMLAttribute("media");
|
||||
}
|
||||
|
||||
public void setMedia(String media)
|
||||
{
|
||||
setHTMLAttribute("media", media);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/* DomHTMLTableCaptionElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLTableCaptionElement;
|
||||
|
||||
/**
|
||||
* An HTML 'CAPTION' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableCaptionElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableCaptionElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableCaptionElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
/* DomHTMLTableCellElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLTableCellElement;
|
||||
|
||||
/**
|
||||
* An HTML 'TH' or 'TD' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableCellElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableCellElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableCellElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public int getCellIndex()
|
||||
{
|
||||
return getIndex();
|
||||
}
|
||||
|
||||
public String getAbbr()
|
||||
{
|
||||
return getHTMLAttribute("abbr");
|
||||
}
|
||||
|
||||
public void setAbbr(String abbr)
|
||||
{
|
||||
setHTMLAttribute("abbr", abbr);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getAxis()
|
||||
{
|
||||
return getHTMLAttribute("axis");
|
||||
}
|
||||
|
||||
public void setAxis(String axis)
|
||||
{
|
||||
setHTMLAttribute("axis", axis);
|
||||
}
|
||||
|
||||
public String getBgColor()
|
||||
{
|
||||
return getHTMLAttribute("bgcolor");
|
||||
}
|
||||
|
||||
public void setBgColor(String bgColor)
|
||||
{
|
||||
setHTMLAttribute("bgcolor", bgColor);
|
||||
}
|
||||
|
||||
public String getCh()
|
||||
{
|
||||
return getHTMLAttribute("char");
|
||||
}
|
||||
|
||||
public void setCh(String ch)
|
||||
{
|
||||
setHTMLAttribute("char", ch);
|
||||
}
|
||||
|
||||
public String getChOff()
|
||||
{
|
||||
return getHTMLAttribute("charoff");
|
||||
}
|
||||
|
||||
public void setChOff(String chOff)
|
||||
{
|
||||
setHTMLAttribute("charoff", chOff);
|
||||
}
|
||||
|
||||
public int getColSpan()
|
||||
{
|
||||
return getIntHTMLAttribute("colspan");
|
||||
}
|
||||
|
||||
public void setColSpan(int colSpan)
|
||||
{
|
||||
setIntHTMLAttribute("colspan", colSpan);
|
||||
}
|
||||
|
||||
public String getHeaders()
|
||||
{
|
||||
return getHTMLAttribute("headers");
|
||||
}
|
||||
|
||||
public void setHeaders(String headers)
|
||||
{
|
||||
setHTMLAttribute("headers", headers);
|
||||
}
|
||||
|
||||
public String getHeight()
|
||||
{
|
||||
return getHTMLAttribute("height");
|
||||
}
|
||||
|
||||
public void setHeight(String height)
|
||||
{
|
||||
setHTMLAttribute("height", height);
|
||||
}
|
||||
|
||||
public boolean getNoWrap()
|
||||
{
|
||||
return getBooleanHTMLAttribute("nowrap");
|
||||
}
|
||||
|
||||
public void setNoWrap(boolean noWrap)
|
||||
{
|
||||
setBooleanHTMLAttribute("nowrap", noWrap);
|
||||
}
|
||||
|
||||
public int getRowSpan()
|
||||
{
|
||||
return getIntHTMLAttribute("rowspan");
|
||||
}
|
||||
|
||||
public void setRowSpan(int rowSpan)
|
||||
{
|
||||
setIntHTMLAttribute("rowspan", rowSpan);
|
||||
}
|
||||
|
||||
public String getScope()
|
||||
{
|
||||
return getHTMLAttribute("scope");
|
||||
}
|
||||
|
||||
public void setScope(String scope)
|
||||
{
|
||||
setHTMLAttribute("scope", scope);
|
||||
}
|
||||
|
||||
public String getVAlign()
|
||||
{
|
||||
return getHTMLAttribute("valign");
|
||||
}
|
||||
|
||||
public void setVAlign(String vAlign)
|
||||
{
|
||||
setHTMLAttribute("valign", vAlign);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/* DomHTMLTableColElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLTableColElement;
|
||||
|
||||
/**
|
||||
* An HTML 'COL' or 'COLGROUP' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableColElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableColElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableColElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getCh()
|
||||
{
|
||||
return getHTMLAttribute("char");
|
||||
}
|
||||
|
||||
public void setCh(String ch)
|
||||
{
|
||||
setHTMLAttribute("char", ch);
|
||||
}
|
||||
|
||||
public String getChOff()
|
||||
{
|
||||
return getHTMLAttribute("charoff");
|
||||
}
|
||||
|
||||
public void setChOff(String chOff)
|
||||
{
|
||||
setHTMLAttribute("charoff", chOff);
|
||||
}
|
||||
|
||||
public int getSpan()
|
||||
{
|
||||
return getIntHTMLAttribute("span");
|
||||
}
|
||||
|
||||
public void setSpan(int span)
|
||||
{
|
||||
setIntHTMLAttribute("span", span);
|
||||
}
|
||||
|
||||
public String getVAlign()
|
||||
{
|
||||
return getHTMLAttribute("valign");
|
||||
}
|
||||
|
||||
public void setVAlign(String vAlign)
|
||||
{
|
||||
setHTMLAttribute("valign", vAlign);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
/* DomHTMLTableElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
import org.w3c.dom.html2.HTMLTableCaptionElement;
|
||||
import org.w3c.dom.html2.HTMLTableElement;
|
||||
import org.w3c.dom.html2.HTMLTableSectionElement;
|
||||
|
||||
/**
|
||||
* An HTML 'TABLE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public HTMLTableCaptionElement getCaption()
|
||||
{
|
||||
return (HTMLTableCaptionElement) getChildElement("caption");
|
||||
}
|
||||
|
||||
public void setCaption(HTMLTableCaptionElement caption)
|
||||
{
|
||||
HTMLTableCaptionElement ref = getCaption();
|
||||
if (ref == null)
|
||||
{
|
||||
appendChild(caption);
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceChild(caption, ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLTableSectionElement getTHead()
|
||||
{
|
||||
return (HTMLTableSectionElement) getChildElement("thead");
|
||||
}
|
||||
|
||||
public void setTHead(HTMLTableSectionElement tHead)
|
||||
{
|
||||
HTMLTableSectionElement ref = getTHead();
|
||||
if (ref == null)
|
||||
{
|
||||
appendChild(tHead);
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceChild(tHead, ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLTableSectionElement getTFoot()
|
||||
{
|
||||
return (HTMLTableSectionElement) getChildElement("tfoot");
|
||||
}
|
||||
|
||||
public void setTFoot(HTMLTableSectionElement tFoot)
|
||||
{
|
||||
HTMLTableSectionElement ref = getTFoot();
|
||||
if (ref == null)
|
||||
{
|
||||
appendChild(tFoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceChild(tFoot, ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLCollection getRows()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("tr");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLCollection getTBodies()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("tbody");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getBgColor()
|
||||
{
|
||||
return getHTMLAttribute("bgcolor");
|
||||
}
|
||||
|
||||
public void setBgColor(String bgColor)
|
||||
{
|
||||
setHTMLAttribute("bgcolor", bgColor);
|
||||
}
|
||||
|
||||
public String getBorder()
|
||||
{
|
||||
return getHTMLAttribute("border");
|
||||
}
|
||||
|
||||
public void setBorder(String border)
|
||||
{
|
||||
setHTMLAttribute("border", border);
|
||||
}
|
||||
|
||||
public String getCellPadding()
|
||||
{
|
||||
return getHTMLAttribute("cellpadding");
|
||||
}
|
||||
|
||||
public void setCellPadding(String cellPadding)
|
||||
{
|
||||
setHTMLAttribute("cellpadding", cellPadding);
|
||||
}
|
||||
|
||||
public String getCellSpacing()
|
||||
{
|
||||
return getHTMLAttribute("cellspacing");
|
||||
}
|
||||
|
||||
public void setCellSpacing(String cellSpacing)
|
||||
{
|
||||
setHTMLAttribute("cellspacing", cellSpacing);
|
||||
}
|
||||
|
||||
public String getFrame()
|
||||
{
|
||||
return getHTMLAttribute("frame");
|
||||
}
|
||||
|
||||
public void setFrame(String frame)
|
||||
{
|
||||
setHTMLAttribute("frame", frame);
|
||||
}
|
||||
|
||||
public String getRules()
|
||||
{
|
||||
return getHTMLAttribute("rules");
|
||||
}
|
||||
|
||||
public void setRules(String rules)
|
||||
{
|
||||
setHTMLAttribute("rules", rules);
|
||||
}
|
||||
|
||||
public String getSummary()
|
||||
{
|
||||
return getHTMLAttribute("summary");
|
||||
}
|
||||
|
||||
public void setSummary(String summary)
|
||||
{
|
||||
setHTMLAttribute("summary", summary);
|
||||
}
|
||||
|
||||
public String getWidth()
|
||||
{
|
||||
return getHTMLAttribute("width");
|
||||
}
|
||||
|
||||
public void setWidth(String width)
|
||||
{
|
||||
setHTMLAttribute("width", width);
|
||||
}
|
||||
|
||||
public HTMLElement createTHead()
|
||||
{
|
||||
HTMLTableSectionElement ref = getTHead();
|
||||
if (ref == null)
|
||||
{
|
||||
return (HTMLElement) getOwnerDocument().createElement("thead");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTHead()
|
||||
{
|
||||
HTMLTableSectionElement ref = getTHead();
|
||||
if (ref != null)
|
||||
{
|
||||
removeChild(ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLElement createTFoot()
|
||||
{
|
||||
HTMLTableSectionElement ref = getTFoot();
|
||||
if (ref == null)
|
||||
{
|
||||
return (HTMLElement) getOwnerDocument().createElement("tfoot");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTFoot()
|
||||
{
|
||||
HTMLTableSectionElement ref = getTFoot();
|
||||
if (ref != null)
|
||||
{
|
||||
removeChild(ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLElement createCaption()
|
||||
{
|
||||
HTMLTableCaptionElement ref = getCaption();
|
||||
if (ref == null)
|
||||
{
|
||||
return (HTMLElement) getOwnerDocument().createElement("caption");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteCaption()
|
||||
{
|
||||
HTMLTableCaptionElement ref = getCaption();
|
||||
if (ref != null)
|
||||
{
|
||||
removeChild(ref);
|
||||
}
|
||||
}
|
||||
|
||||
public HTMLElement insertRow(int index)
|
||||
{
|
||||
Node ref = getRow(index);
|
||||
Node row = getOwnerDocument().createElement("tr");
|
||||
if (ref == null)
|
||||
{
|
||||
Node tbody = getChildElement("tbody");
|
||||
if (tbody == null)
|
||||
{
|
||||
tbody = getOwnerDocument().createElement("tfoot");
|
||||
appendChild(tbody);
|
||||
}
|
||||
tbody.appendChild(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
ref.getParentNode().insertBefore(row, ref);
|
||||
}
|
||||
return (HTMLElement) row;
|
||||
}
|
||||
|
||||
public void deleteRow(int index)
|
||||
{
|
||||
Node ref = getRow(index);
|
||||
if (ref == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
ref.getParentNode().removeChild(ref);
|
||||
}
|
||||
|
||||
Node getRow(final int index)
|
||||
{
|
||||
int i = 0;
|
||||
Node thead = getChildElement("thead");
|
||||
if (thead != null)
|
||||
{
|
||||
for (Node ctx = thead.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
String ctxName = ctx.getLocalName();
|
||||
if (ctxName == null)
|
||||
{
|
||||
ctxName = ctx.getNodeName();
|
||||
}
|
||||
if (!"tr".equalsIgnoreCase(ctxName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == i)
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Node tbody = getChildElement("tbody");
|
||||
if (tbody == null)
|
||||
{
|
||||
tbody = this;
|
||||
}
|
||||
for (Node ctx = tbody.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
String ctxName = ctx.getLocalName();
|
||||
if (ctxName == null)
|
||||
{
|
||||
ctxName = ctx.getNodeName();
|
||||
}
|
||||
if (!"tr".equalsIgnoreCase(ctxName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == i)
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
Node tfoot = getChildElement("tfoot");
|
||||
if (tfoot != null)
|
||||
{
|
||||
for (Node ctx = tfoot.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
String ctxName = ctx.getLocalName();
|
||||
if (ctxName == null)
|
||||
{
|
||||
ctxName = ctx.getNodeName();
|
||||
}
|
||||
if (!"tr".equalsIgnoreCase(ctxName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == i)
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/* DomHTMLTableRowElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
import org.w3c.dom.html2.HTMLTableRowElement;
|
||||
|
||||
/**
|
||||
* An HTML 'TR' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableRowElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableRowElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableRowElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public int getRowIndex()
|
||||
{
|
||||
return getIndex();
|
||||
}
|
||||
|
||||
public int getSectionRowIndex()
|
||||
{
|
||||
int index = 0;
|
||||
DomHTMLElement parent = (DomHTMLElement) getParentElement("table");
|
||||
if (parent != null)
|
||||
{
|
||||
Node thead = parent.getChildElement("thead");
|
||||
if (thead != null)
|
||||
{
|
||||
for (Node ctx = thead.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
if (ctx == this)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Node tbody = parent.getChildElement("tbody");
|
||||
if (tbody != null)
|
||||
{
|
||||
for (Node ctx = tbody.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
if (ctx == this)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Node tfoot = parent.getChildElement("tfoot");
|
||||
if (tfoot != null)
|
||||
{
|
||||
for (Node ctx = tfoot.getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
if (ctx == this)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new DomDOMException(DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
|
||||
public HTMLCollection getCells()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("th");
|
||||
ret.addNodeName("td");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getBgColor()
|
||||
{
|
||||
return getHTMLAttribute("bgcolor");
|
||||
}
|
||||
|
||||
public void setBgColor(String bgColor)
|
||||
{
|
||||
setHTMLAttribute("bgcolor", bgColor);
|
||||
}
|
||||
|
||||
public String getCh()
|
||||
{
|
||||
return getHTMLAttribute("char");
|
||||
}
|
||||
|
||||
public void setCh(String ch)
|
||||
{
|
||||
setHTMLAttribute("char", ch);
|
||||
}
|
||||
|
||||
public String getChOff()
|
||||
{
|
||||
return getHTMLAttribute("charoff");
|
||||
}
|
||||
|
||||
public void setChOff(String chOff)
|
||||
{
|
||||
setHTMLAttribute("charoff", chOff);
|
||||
}
|
||||
|
||||
public String getVAlign()
|
||||
{
|
||||
return getHTMLAttribute("valign");
|
||||
}
|
||||
|
||||
public void setVAlign(String vAlign)
|
||||
{
|
||||
setHTMLAttribute("valign", vAlign);
|
||||
}
|
||||
|
||||
public HTMLElement insertCell(int index)
|
||||
{
|
||||
Node ref = getCell(index);
|
||||
Node cell = getOwnerDocument().createElement("td");
|
||||
if (ref == null)
|
||||
{
|
||||
appendChild(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
insertBefore(cell, ref);
|
||||
}
|
||||
return (HTMLElement) cell;
|
||||
}
|
||||
|
||||
public void deleteCell(int index)
|
||||
{
|
||||
Node ref = getCell(index);
|
||||
if (ref == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
removeChild(ref);
|
||||
}
|
||||
|
||||
Node getCell(final int index)
|
||||
{
|
||||
int i = 0;
|
||||
for (Node ctx = getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
String name = ctx.getLocalName();
|
||||
if (name == null)
|
||||
{
|
||||
name = ctx.getNodeName();
|
||||
}
|
||||
if (!"td".equalsIgnoreCase(name) &&
|
||||
!"th".equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == i)
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/* DomHTMLTableSectionElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import gnu.xml.dom.DomDOMException;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.html2.HTMLCollection;
|
||||
import org.w3c.dom.html2.HTMLElement;
|
||||
import org.w3c.dom.html2.HTMLTableSectionElement;
|
||||
|
||||
/**
|
||||
* An HTML 'THEAD', 'TFOOT', or 'TBODY' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTableSectionElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTableSectionElement
|
||||
{
|
||||
|
||||
protected DomHTMLTableSectionElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getAlign()
|
||||
{
|
||||
return getHTMLAttribute("align");
|
||||
}
|
||||
|
||||
public void setAlign(String align)
|
||||
{
|
||||
setHTMLAttribute("align", align);
|
||||
}
|
||||
|
||||
public String getCh()
|
||||
{
|
||||
return getHTMLAttribute("char");
|
||||
}
|
||||
|
||||
public void setCh(String ch)
|
||||
{
|
||||
setHTMLAttribute("char", ch);
|
||||
}
|
||||
|
||||
public String getChOff()
|
||||
{
|
||||
return getHTMLAttribute("charoff");
|
||||
}
|
||||
|
||||
public void setChOff(String chOff)
|
||||
{
|
||||
setHTMLAttribute("charoff", chOff);
|
||||
}
|
||||
|
||||
public String getVAlign()
|
||||
{
|
||||
return getHTMLAttribute("valign");
|
||||
}
|
||||
|
||||
public void setVAlign(String vAlign)
|
||||
{
|
||||
setHTMLAttribute("valign", vAlign);
|
||||
}
|
||||
|
||||
public HTMLCollection getRows()
|
||||
{
|
||||
DomHTMLCollection ret =
|
||||
new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
|
||||
ret.addNodeName("tr");
|
||||
ret.evaluate();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HTMLElement insertRow(int index)
|
||||
{
|
||||
Node ref = getRow(index);
|
||||
Node row = getOwnerDocument().createElement("tr");
|
||||
if (ref == null)
|
||||
{
|
||||
appendChild(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
insertBefore(row, ref);
|
||||
}
|
||||
return (HTMLElement) row;
|
||||
}
|
||||
|
||||
public void deleteRow(int index)
|
||||
{
|
||||
Node ref = getRow(index);
|
||||
if (ref == null)
|
||||
{
|
||||
throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
removeChild(ref);
|
||||
}
|
||||
|
||||
Node getRow(final int index)
|
||||
{
|
||||
int i = 0;
|
||||
for (Node ctx = getFirstChild(); ctx != null;
|
||||
ctx = ctx.getNextSibling())
|
||||
{
|
||||
String name = ctx.getLocalName();
|
||||
if (name == null)
|
||||
{
|
||||
name = ctx.getNodeName();
|
||||
}
|
||||
if (!"tr".equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == i)
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/* DomHTMLTextAreaElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLFormElement;
|
||||
import org.w3c.dom.html2.HTMLTextAreaElement;
|
||||
|
||||
/**
|
||||
* An HTML 'TEXTAREA' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTextAreaElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTextAreaElement
|
||||
{
|
||||
|
||||
protected String value;
|
||||
|
||||
protected DomHTMLTextAreaElement(DomHTMLDocument owner,
|
||||
String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return getHTMLAttribute("value");
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue)
|
||||
{
|
||||
setHTMLAttribute("value", defaultValue);
|
||||
}
|
||||
|
||||
public HTMLFormElement getForm()
|
||||
{
|
||||
return (HTMLFormElement) getParentElement("form");
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return getHTMLAttribute("accesskey");
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
setHTMLAttribute("accesskey", accessKey);
|
||||
}
|
||||
|
||||
public int getCols()
|
||||
{
|
||||
return getIntHTMLAttribute("cols");
|
||||
}
|
||||
|
||||
public void setCols(int cols)
|
||||
{
|
||||
setIntHTMLAttribute("cols", cols);
|
||||
}
|
||||
|
||||
public boolean getDisabled()
|
||||
{
|
||||
return getBooleanHTMLAttribute("disabled");
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
{
|
||||
setBooleanHTMLAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getHTMLAttribute("name");
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
setHTMLAttribute("name", name);
|
||||
}
|
||||
|
||||
public boolean getReadOnly()
|
||||
{
|
||||
return getBooleanHTMLAttribute("readOnly");
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly)
|
||||
{
|
||||
setBooleanHTMLAttribute("readonly", readOnly);
|
||||
}
|
||||
|
||||
public int getRows()
|
||||
{
|
||||
return getIntHTMLAttribute("rows");
|
||||
}
|
||||
|
||||
public void setRows(int rows)
|
||||
{
|
||||
setIntHTMLAttribute("rows", rows);
|
||||
}
|
||||
|
||||
public int getTabIndex()
|
||||
{
|
||||
return getIntHTMLAttribute("tabindex");
|
||||
}
|
||||
|
||||
public void setTabIndex(int tabIndex)
|
||||
{
|
||||
setIntHTMLAttribute("tabindex", tabIndex);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return "textarea";
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = getDefaultValue();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void blur()
|
||||
{
|
||||
dispatchUIEvent("blur");
|
||||
}
|
||||
|
||||
public void focus()
|
||||
{
|
||||
dispatchUIEvent("focus");
|
||||
}
|
||||
|
||||
public void select()
|
||||
{
|
||||
dispatchUIEvent("select");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* DomHTMLTitleElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLTitleElement;
|
||||
|
||||
/**
|
||||
* An HTML 'TITLE' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLTitleElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLTitleElement
|
||||
{
|
||||
|
||||
protected DomHTMLTitleElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return getTextContent();
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
setTextContent(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DomHTMLUListElement.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.html2;
|
||||
|
||||
import org.w3c.dom.html2.HTMLUListElement;
|
||||
|
||||
/**
|
||||
* An HTML 'UL' element node.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomHTMLUListElement
|
||||
extends DomHTMLElement
|
||||
implements HTMLUListElement
|
||||
{
|
||||
|
||||
protected DomHTMLUListElement(DomHTMLDocument owner, String namespaceURI,
|
||||
String name)
|
||||
{
|
||||
super(owner, namespaceURI, name);
|
||||
}
|
||||
|
||||
public boolean getCompact()
|
||||
{
|
||||
return getBooleanHTMLAttribute("compact");
|
||||
}
|
||||
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
setBooleanHTMLAttribute("compact", compact);
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return getHTMLAttribute("type");
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
setHTMLAttribute("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/* DomLSException.java --
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.ls;
|
||||
|
||||
import org.w3c.dom.ls.LSException;
|
||||
|
||||
/**
|
||||
* A DOM LS exception incorporating a cause.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomLSException
|
||||
extends LSException
|
||||
{
|
||||
|
||||
public DomLSException(short type, Exception cause)
|
||||
{
|
||||
super(type, (cause == null) ? null : cause.getMessage());
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/* DomLSInput.java --
|
||||
Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.dom.ls;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import org.w3c.dom.ls.LSInput;
|
||||
|
||||
/**
|
||||
* Specification of XML input to parse.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class DomLSInput
|
||||
implements LSInput
|
||||
{
|
||||
|
||||
private InputStream in;
|
||||
private String systemId;
|
||||
private String publicId;
|
||||
private String baseURI;
|
||||
private String encoding;
|
||||
private boolean certifiedText;
|
||||
|
||||
public Reader getCharacterStream()
|
||||
{
|
||||
return new InputStreamReader(in);
|
||||
}
|
||||
|
||||
public void setCharacterStream(Reader characterStream)
|
||||
{
|
||||
in = new ReaderInputStream(characterStream);
|
||||
}
|
||||
|
||||
public InputStream getByteStream()
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
public void setByteStream(InputStream byteStream)
|
||||
{
|
||||
in = byteStream;
|
||||
}
|
||||
|
||||
public String getStringData()
|
||||
{
|
||||
StringBuffer acc = new StringBuffer();
|
||||
Reader reader = getCharacterStream();
|
||||
try
|
||||
{
|
||||
char[] buf = new char[4096];
|
||||
for (int len = reader.read(buf); len != -1; len = reader.read(buf))
|
||||
{
|
||||
acc.append(buf, 0, len);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return null; // ?
|
||||
}
|
||||
return acc.toString();
|
||||
}
|
||||
|
||||
public void setStringData(String stringData)
|
||||
{
|
||||
in = new ReaderInputStream(new StringReader(stringData));
|
||||
}
|
||||
|
||||
public String getSystemId()
|
||||
{
|
||||
return systemId;
|
||||
}
|
||||
|
||||
public void setSystemId(String systemId)
|
||||
{
|
||||
this.systemId = systemId;
|
||||
}
|
||||
|
||||
public String getPublicId()
|
||||
{
|
||||
return publicId;
|
||||
}
|
||||
|
||||
public void setPublicId(String publicId)
|
||||
{
|
||||
this.publicId = publicId;
|
||||
}
|
||||
|
||||
public String getBaseURI()
|
||||
{
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
public void setBaseURI(String baseURI)
|
||||
{
|
||||
this.baseURI = baseURI;
|
||||
}
|
||||
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public boolean getCertifiedText()
|
||||
{
|
||||
return certifiedText;
|
||||
}
|
||||
|
||||
public void setCertifiedText(boolean certifiedText)
|
||||
{
|
||||
this.certifiedText = certifiedText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user