Initial commit

This commit is contained in:
github-classroom[bot] 2023-03-06 13:35:46 +00:00 committed by GitHub
commit 5af7724e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
739 changed files with 220926 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
virtualenv/

12
readme.md Normal file
View File

@ -0,0 +1,12 @@
### Information Modelling & Analysis: Project 1
Student: *enter your name here*
### Project instructions:
Please follow the instructions provided in the project slides.
For your convenience, the source code to be analyzed (xerces2)
has already been added to this repository (*/resources/xerces2-j-src*).
**Attention**: Please consider the submission instructions available on iCorsi.
**Report**: You may want to use the template distributed on iCorsi.

View File

@ -0,0 +1,119 @@
Manifest-Version: 1.0
Created-By: @java.version@ (@java.vendor@)
Name: org/apache/xerces/impl/
Comment: @impl.name@
Implementation-Title: org.apache.xerces.impl.Version
Implementation-Version: @impl.version@
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xerces.apache.org/xerces2-j/
Name: org/xml/sax/
Comment: based on xml-commons external 1.4.01
Specification-Title: Simple API for XML
Specification-Vendor: David Megginson
Specification-Version: 2.0.2
Implementation-Title: org.xml.sax
Implementation-Version: 2.0.2
Implementation-Vendor: David Megginson
Implementation-URL: http://www.saxproject.org/
Name: org/w3c/dom/
Comment: based on xml-commons external 1.4.01
Specification-Title: Document Object Model, Level 3 Core
Specification-Vendor: World Wide Web Consortium
Specification-Version: 1.0
Implementation-Title: org.w3c.dom
Implementation-Version: 1.0
Implementation-Vendor: World Wide Web Consortium
Implementation-URL: http://www.w3c.org/DOM/
Name: org/w3c/dom/ls/
Comment: based on xml-commons external 1.4.01
Specification-Title: Document Object Model, Level 3 Load and Save
Specification-Vendor: World Wide Web Consortium
Specification-Version: 1.0
Implementation-Title: org.w3c.dom.ls
Implementation-Version: 1.0
Implementation-Vendor: World Wide Web Consortium
Implementation-URL: http://www.w3c.org/DOM/
Name: javax/xml/stream/
Comment: based on xml-commons external 1.4.01
Specification-Title: Streaming API for XML
Specification-Vendor: BEA Systems, Inc.
Specification-Version: 1.0
Implementation-Title: javax.xml.stream
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/datatype/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.datatype
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/namespace/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.namespace
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/parsers/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.parsers
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/transform/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.transform
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/validation/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.validation
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: javax/xml/xpath/
Comment: based on xml-commons external 1.4.01
Specification-Title: Java API for XML Processing
Specification-Version: 1.4
Specification-Vendor: Sun Microsystems Inc.
Implementation-Title: javax.xml.xpath
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/
Name: org/apache/xerces/xni/
Comment: Xerces Native Interface
Specification-Title: Xerces Native Interface
Specification-Version: 1.2
Specification-Vendor: Apache Software Foundation
Implementation-Title: org.apache.xerces.xni
Implementation-Version: 1.2
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xerces.apache.org/xerces2-j/

View File

@ -0,0 +1,210 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLAnchorElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLAnchorElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLAnchorElementImpl
extends HTMLElementImpl
implements HTMLAnchorElement
{
private static final long serialVersionUID = -140558580924061847L;
public String getAccessKey()
{
String accessKey;
// Make sure that the access key is a single character.
accessKey = getAttribute( "accesskey" );
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
return accessKey;
}
public void setAccessKey( String accessKey )
{
// Make sure that the access key is a single character.
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
setAttribute( "accesskey", accessKey );
}
public String getCharset()
{
return getAttribute( "charset" );
}
public void setCharset( String charset )
{
setAttribute( "charset", charset );
}
public String getCoords()
{
return getAttribute( "coords" );
}
public void setCoords( String coords )
{
setAttribute( "coords", coords );
}
public String getHref()
{
return getAttribute( "href" );
}
public void setHref( String href )
{
setAttribute( "href", href );
}
public String getHreflang()
{
return getAttribute( "hreflang" );
}
public void setHreflang( String hreflang )
{
setAttribute( "hreflang", hreflang );
}
public String getName()
{
return getAttribute( "name" );
}
public void setName( String name )
{
setAttribute( "name", name );
}
public String getRel()
{
return getAttribute( "rel" );
}
public void setRel( String rel )
{
setAttribute( "rel", rel );
}
public String getRev()
{
return getAttribute( "rev" );
}
public void setRev( String rev )
{
setAttribute( "rev", rev );
}
public String getShape()
{
return capitalize( getAttribute( "shape" ) );
}
public void setShape( String shape )
{
setAttribute( "shape", shape );
}
public int getTabIndex()
{
return this.getInteger( getAttribute( "tabindex" ) );
}
public void setTabIndex( int tabIndex )
{
setAttribute( "tabindex", String.valueOf( tabIndex ) );
}
public String getTarget()
{
return getAttribute( "target" );
}
public void setTarget( String target )
{
setAttribute( "target", target );
}
public String getType()
{
return getAttribute( "type" );
}
public void setType( String type )
{
setAttribute( "type", type );
}
public void blur()
{
// No scripting in server-side DOM. This method is moot.
}
public void focus()
{
// No scripting in server-side DOM. This method is moot.
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLAnchorElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,178 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLAppletElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLAppletElement
* @see HTMLElementImpl
*/
public class HTMLAppletElementImpl
extends HTMLElementImpl
implements HTMLAppletElement
{
private static final long serialVersionUID = 8375794094117740967L;
public String getAlign()
{
return getAttribute( "align" );
}
public void setAlign( String align )
{
setAttribute( "align", align );
}
public String getAlt()
{
return getAttribute( "alt" );
}
public void setAlt( String alt )
{
setAttribute( "alt", alt );
}
public String getArchive()
{
return getAttribute( "archive" );
}
public void setArchive( String archive )
{
setAttribute( "archive", archive );
}
public String getCode()
{
return getAttribute( "code" );
}
public void setCode( String code )
{
setAttribute( "code", code );
}
public String getCodeBase()
{
return getAttribute( "codebase" );
}
public void setCodeBase( String codeBase )
{
setAttribute( "codebase", codeBase );
}
public String getHeight()
{
return getAttribute( "height" );
}
public void setHeight( String height )
{
setAttribute( "height", height );
}
public String getHspace()
{
return getAttribute( "height" );
}
public void setHspace( String height )
{
setAttribute( "height", height );
}
public String getName()
{
return getAttribute( "name" );
}
public void setName( String name )
{
setAttribute( "name", name );
}
public String getObject()
{
return getAttribute( "object" );
}
public void setObject( String object )
{
setAttribute( "object", object );
}
public String getVspace()
{
return getAttribute( "vspace" );
}
public void setVspace( String vspace )
{
setAttribute( "vspace", vspace );
}
public String getWidth()
{
return getAttribute( "width" );
}
public void setWidth( String width )
{
setAttribute( "width", width );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLAppletElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,150 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLAreaElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLAreaElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLAreaElementImpl
extends HTMLElementImpl
implements HTMLAreaElement
{
private static final long serialVersionUID = 7164004431531608995L;
public String getAccessKey()
{
String accessKey;
// Make sure that the access key is a single character.
accessKey = getAttribute( "accesskey" );
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
return accessKey;
}
public void setAccessKey( String accessKey )
{
// Make sure that the access key is a single character.
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
setAttribute( "accesskey", accessKey );
}
public String getAlt()
{
return getAttribute( "alt" );
}
public void setAlt( String alt )
{
setAttribute( "alt", alt );
}
public String getCoords()
{
return getAttribute( "coords" );
}
public void setCoords( String coords )
{
setAttribute( "coords", coords );
}
public String getHref()
{
return getAttribute( "href" );
}
public void setHref( String href )
{
setAttribute( "href", href );
}
public boolean getNoHref()
{
return getBinary( "nohref" );
}
public void setNoHref( boolean noHref )
{
setAttribute( "nohref", noHref );
}
public String getShape()
{
return capitalize( getAttribute( "shape" ) );
}
public void setShape( String shape )
{
setAttribute( "shape", shape );
}
public int getTabIndex()
{
return getInteger( getAttribute( "tabindex" ) );
}
public void setTabIndex( int tabIndex )
{
setAttribute( "tabindex", String.valueOf( tabIndex ) );
}
public String getTarget()
{
return getAttribute( "target" );
}
public void setTarget( String target )
{
setAttribute( "target", target );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLAreaElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLBRElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLBRElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLBRElementImpl
extends HTMLElementImpl
implements HTMLBRElement
{
private static final long serialVersionUID = 311960206282154750L;
public String getClear()
{
return capitalize( getAttribute( "clear" ) );
}
public void setClear( String clear )
{
setAttribute( "clear", clear );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLBRElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLBaseElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLBaseElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLBaseElementImpl
extends HTMLElementImpl
implements HTMLBaseElement
{
private static final long serialVersionUID = -396648580810072153L;
public String getHref()
{
return getAttribute( "href" );
}
public void setHref( String href )
{
setAttribute( "href", href );
}
public String getTarget()
{
return getAttribute( "target" );
}
public void setTarget( String target )
{
setAttribute( "target", target );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLBaseElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLBaseFontElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLBaseFontElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLBaseFontElementImpl
extends HTMLElementImpl
implements HTMLBaseFontElement
{
private static final long serialVersionUID = -3650249921091097229L;
public String getColor()
{
return capitalize( getAttribute( "color" ) );
}
public void setColor( String color )
{
setAttribute( "color", color );
}
public String getFace()
{
return capitalize( getAttribute( "face" ) );
}
public void setFace( String face )
{
setAttribute( "face", face );
}
public String getSize()
{
return getAttribute( "size" );
}
public void setSize( String size )
{
setAttribute( "size", size );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLBaseFontElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,119 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLBodyElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLBodyElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLBodyElementImpl
extends HTMLElementImpl
implements HTMLBodyElement
{
private static final long serialVersionUID = 9058852459426595202L;
public String getALink()
{
return getAttribute( "alink" );
}
public void setALink(String aLink)
{
setAttribute( "alink", aLink );
}
public String getBackground()
{
return getAttribute( "background" );
}
public void setBackground( String background )
{
setAttribute( "background", background );
}
public String getBgColor()
{
return getAttribute( "bgcolor" );
}
public void setBgColor(String bgColor)
{
setAttribute( "bgcolor", bgColor );
}
public String getLink()
{
return getAttribute( "link" );
}
public void setLink(String link)
{
setAttribute( "link", link );
}
public String getText()
{
return getAttribute( "text" );
}
public void setText(String text)
{
setAttribute( "text", text );
}
public String getVLink()
{
return getAttribute( "vlink" );
}
public void setVLink(String vLink)
{
setAttribute( "vlink", vLink );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLBodyElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,227 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import java.util.Vector;
import org.apache.xerces.dom.ElementImpl;
import org.apache.xerces.dom.ProcessingInstructionImpl;
import org.w3c.dom.Node;
import org.w3c.dom.html.HTMLDocument;
import org.xml.sax.AttributeList;
import org.xml.sax.DocumentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
/**
* This is a SAX document handler that is used to build an HTML document.
* It can build a document from any SAX parser, but is specifically tuned
* for working with the OpenXML HTML parser.
*
*
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@openxml.org">Assaf Arkin</a>
*/
public class HTMLBuilder
implements DocumentHandler
{
/**
* The document that is being built.
*/
protected HTMLDocumentImpl _document;
/**
* The current node in the document into which elements, text and
* other nodes will be inserted. This starts as the document itself
* and reflects each element that is currently being parsed.
*/
protected ElementImpl _current;
/**
* Applies only to whitespace appearing between element tags in element content,
* as per the SAX definition, and true by default.
*/
private boolean _ignoreWhitespace = true;
/**
* Indicates whether finished building a document. If so, can start building
* another document. Must be initially true to get the first document processed.
*/
private boolean _done = true;
/**
* The document is only created the same time as the document element, however, certain
* nodes may precede the document element (comment and PI), and they are accumulated
* in this vector.
*/
protected Vector _preRootNodes;
public void startDocument()
throws SAXException
{
if ( ! _done )
throw new SAXException( "HTM001 State error: startDocument fired twice on one builder." );
_document = null;
_done = false;
}
public void endDocument()
throws SAXException
{
if ( _document == null )
throw new SAXException( "HTM002 State error: document never started or missing document element." );
if ( _current != null )
throw new SAXException( "HTM003 State error: document ended before end of document element." );
_current = null;
_done = true;
}
public synchronized void startElement( String tagName, AttributeList attrList )
throws SAXException
{
ElementImpl elem;
int i;
if ( tagName == null )
throw new SAXException( "HTM004 Argument 'tagName' is null." );
// If this is the root element, this is the time to create a new document,
// because only know we know the document element name and namespace URI.
if ( _document == null )
{
// No need to create the element explicitly.
_document = new HTMLDocumentImpl();
elem = (ElementImpl) _document.getDocumentElement();
_current = elem;
if ( _current == null )
throw new SAXException( "HTM005 State error: Document.getDocumentElement returns null." );
// Insert nodes (comment and PI) that appear before the root element.
if ( _preRootNodes != null )
{
for ( i = _preRootNodes.size() ; i-- > 0 ; )
_document.insertBefore( (Node) _preRootNodes.elementAt( i ), elem );
_preRootNodes = null;
}
}
else
{
// This is a state error, indicates that document has been parsed in full,
// or that there are two root elements.
if ( _current == null )
throw new SAXException( "HTM006 State error: startElement called after end of document element." );
elem = (ElementImpl) _document.createElement( tagName );
_current.appendChild( elem );
_current = elem;
}
// Add the attributes (specified and not-specified) to this element.
if ( attrList != null )
{
for ( i = 0 ; i < attrList.getLength() ; ++ i )
elem.setAttribute( attrList.getName( i ), attrList.getValue( i ) );
}
}
public void endElement( String tagName )
throws SAXException
{
if ( _current == null )
throw new SAXException( "HTM007 State error: endElement called with no current node." );
if ( ! _current.getNodeName().equalsIgnoreCase( tagName ))
throw new SAXException( "HTM008 State error: mismatch in closing tag name " + tagName + "\n" + tagName);
// Move up to the parent element. When you reach the top (closing the root element).
// the parent is document and current is null.
if ( _current.getParentNode() == _current.getOwnerDocument() )
_current = null;
else
_current = (ElementImpl) _current.getParentNode();
}
public void characters( String text )
throws SAXException
{
if ( _current == null )
throw new SAXException( "HTM009 State error: character data found outside of root element." );
_current.appendChild( _document.createTextNode(text) );
}
public void characters( char[] text, int start, int length )
throws SAXException
{
if ( _current == null )
throw new SAXException( "HTM010 State error: character data found outside of root element." );
_current.appendChild( _document.createTextNode(new String(text, start, length)) );
}
public void ignorableWhitespace( char[] text, int start, int length )
throws SAXException
{
if ( ! _ignoreWhitespace )
_current.appendChild( _document.createTextNode(new String(text, start, length)) );
}
public void processingInstruction( String target, String instruction )
throws SAXException
{
// Processing instruction may appear before the document element (in fact, before the
// document has been created, or after the document element has been closed.
if ( _current == null && _document == null )
{
if ( _preRootNodes == null )
_preRootNodes = new Vector();
_preRootNodes.addElement( new ProcessingInstructionImpl( null, target, instruction ) );
}
else
if ( _current == null && _document != null )
_document.appendChild( _document.createProcessingInstruction(target, instruction) );
else
_current.appendChild( _document.createProcessingInstruction(target, instruction) );
}
public HTMLDocument getHTMLDocument()
{
return _document;
}
public void setDocumentLocator( Locator locator )
{
// ignored
}
}

View File

@ -0,0 +1,129 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.html.dom;
import org.w3c.dom.html.HTMLButtonElement;
/**
* @xerces.internal
* @version $Revision$ $Date$
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
* @see org.w3c.dom.html.HTMLButtonElement
* @see org.apache.xerces.dom.ElementImpl
*/
public class HTMLButtonElementImpl
extends HTMLElementImpl
implements HTMLButtonElement, HTMLFormControl
{
private static final long serialVersionUID = -753685852948076730L;
public String getAccessKey()
{
String accessKey;
// Make sure that the access key is a single character.
accessKey = getAttribute( "accesskey" );
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
return accessKey;
}
public void setAccessKey( String accessKey )
{
// Make sure that the access key is a single character.
if ( accessKey != null && accessKey.length() > 1 )
accessKey = accessKey.substring( 0, 1 );
setAttribute( "accesskey", accessKey );
}
public boolean getDisabled()
{
return getBinary( "disabled" );
}
public void setDisabled( boolean disabled )
{
setAttribute( "disabled", disabled );
}
public String getName()
{
return getAttribute( "name" );
}
public void setName( String name )
{
setAttribute( "name", name );
}
public int getTabIndex()
{
try
{
return Integer.parseInt( getAttribute( "tabindex" ) );
}
catch ( NumberFormatException except )
{
return 0;
}
}
public void setTabIndex( int tabIndex )
{
setAttribute( "tabindex", String.valueOf( tabIndex ) );
}
public String getType()
{
return capitalize( getAttribute( "type" ) );
}
public String getValue()
{
return getAttribute( "value" );
}
public void setValue( String value )
{
setAttribute( "value", value );
}
/**
* Constructor requires owner document.
*
* @param owner The owner HTML document
*/
public HTMLButtonElementImpl( HTMLDocumentImpl owner, String name )
{
super( owner, name );
}
}

View File

@ -0,0 +1,536 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*