dtdparser-1.21/ 0000755 0001750 0001750 00000000000 10302041553 012724 5 ustar arnaud arnaud dtdparser-1.21/source/ 0000755 0001750 0001750 00000000000 07642407457 014252 5 ustar arnaud arnaud dtdparser-1.21/source/com/ 0000755 0001750 0001750 00000000000 07642407457 015030 5 ustar arnaud arnaud dtdparser-1.21/source/com/wutka/ 0000755 0001750 0001750 00000000000 07642407457 016163 5 ustar arnaud arnaud dtdparser-1.21/source/com/wutka/dtd/ 0000755 0001750 0001750 00000000000 10302041462 016707 5 ustar arnaud arnaud dtdparser-1.21/source/com/wutka/dtd/.DTDParser.java.swp 0000644 0001750 0001750 00000100000 07515664513 022243 0 ustar arnaud arnaud b0VIM 5.4 l_9P
/4 mark spot.wutka.com ~mark/jprogs/dtdparser-1.0.1/source/com/wutka/dtd/DTDParser.java 3210#"! U tp P V A L 5 ad 1 P y ^ Z C A "
r Y S R
w
s
D
>
g f 4 3 y x +
}
s
C
B
c y h Z 3 % s i F < 6 5 l ^ z 0 " = < w q p ' { m { if (token.value.equals("EMPTY")) { if (token.type == Scanner.IDENTIFIER) Token token = scanner.get(); { throws IOException protected void parseContentSpec(Scanner scanner, DTDElement element) } parseContentSpec(scanner, element); } dtd.elements.put(element.name, element); element = new DTDElement(name.value); { if (element == null) DTDElement element = (DTDElement) dtd.elements.get(name.value); Token name = expect(Scanner.IDENTIFIER); { throws IOException protected void parseElement() } return token; } } " instead of "+ token.type.name+"("+token.value+")"); throw new IOException("Expected "+expected.name+ { else } " instead of "+token.type.name); throw new IOException("Expected "+expected.name+ { if (token.value == null) { if (token.type != expected) Token token = scanner.get(); { throws IOException protected Token expect(TokenType expected) } } token = scanner.get(); { while (token.type != stopToken) Token token = scanner.get(); { throws IOException protected void skipUntil(TokenType stopToken) } } } skipUntil(Scanner.GT); { else } // Don't need to do anything for this token { else if (token.type == Scanner.ENDCONDITIONAL) } } "Invalid token in conditional: "+token.value); throw new IOException( { else if (!token.value.equals("INCLUDE")) } scanner.skipConditional(); { if (token.value.equals("IGNORE")) token = expect(Scanner.IDENTIFIER); { else if (token.type == Scanner.CONDITIONAL) } return; skipUntil(Scanner.QUESGT); { if (token.type == Scanner.LTQUES) // Is xxx ?> even valid in a DTD? I'll ignore it just in case it's there Token token = scanner.get(); { throws IOException protected void parseTopLevelElement() } return dtd; } parseTopLevelElement(); if (token.type == Scanner.EOF) break; token = scanner.peek(); { for (;;) Token token; { throws IOException public DTD parse() } dtd = new DTD(); scanner = new Scanner(in, trace); { public DTDParser(Reader in, boolean trace) */ * (used for debugging the parser) * @param trace True if the parser should print out tokens as it reads them * @param in The input stream to read /** Creates a parser that will read from the specified Reader object } dtd = new DTD(); scanner = new Scanner(in, false); { public DTDParser(Reader in) /** Creates a parser that will read from the specified Reader object */ protected DTD dtd; protected Scanner scanner; { public class DTDParser */ * @version 1.0 06/28/2000 * @author Mark Wutka * /** Parses a DTD file and returns a DTD object import java.io.*; import java.util.*; package com.wutka.dtd; ad L y O A 0 " p : (
s
]
%
t j i M G F # o n : 9
~
X
1
'
q R Q z P B A } } expect(Scanner.GT); } notation.externalID = pub; } pub.system = token.value; token = scanner.get(); { if (token.type == Scanner.STRING) token = scanner.peek(); // a SystemLiteral // For , you can have PUBLIC PubidLiteral without pub.system = null; pub.pub = token.value; token = expect(Scanner.STRING); DTDPublic pub = new DTDPublic(); { else if (token.value.equals("PUBLIC")) } notation.externalID = sys; sys.system = token.value; token = expect(Scanner.STRING); DTDSystem sys = new DTDSystem(); { if (token.value.equals("SYSTEM")) token = expect(Scanner.IDENTIFIER); dtd.notations.put(notation.name, notation); notation.name = token.value; Token token = expect(Scanner.IDENTIFIER); DTDNotation notation = new DTDNotation(); { throws java.io.IOException protected void parseNotation() } expect(Scanner.GT); } throw new IOException("Invalid entity definition"); { else } } } entity.ndata = token.value; token = expect(Scanner.IDENTIFIER); } "Invalid NData declaration"); throw new IOException( { if (!token.value.equals("NDATA")) { if (token.type == Scanner.IDENTIFIER) token = scanner.peek(); { if (entity.isParsed) } throw new IOException("Invalid External ID specification"); { else } pub.system = token.value; token = expect(Scanner.STRING); pub.pub = token.value; token = expect(Scanner.STRING); ad b V f X 8 * y Z L
|
v
u
C
(
"
g L F ! ~ I ; *
y
x
b
\
[
9
v D m g B A { if (token.value.equals("EMPTY")) { if (token.type == Scanner.IDENTIFIER) Token token = scanner.get(); { throws IOException protected void parseContentSpec(Scanner scanner, DTDElement element) } parseContentSpec(scanner, element); } dtd.elements.put(element.name, element); element = new DTDElement(name.value); { if (element == null) DTDElement element = (DTDElement) dtd.elements.get(name.value); Token name = expect(Scanner.IDENTIFIER); { throws IOException protected void parseElement() } return token; } } " instead of "+ token.type.name+"("+token.value+")"); throw new IOException("Expected "+expected.name+ { else } " instead of "+token.type.name); throw new IOException("Expected "+expected.name+ { if (token.value == null) { if (token.type != expected) Token token = scanner.get(); { throws IOException protected Token expect(TokenType expected) } } token = scanner.get(); { while (token.type != stopToken) Token token = scanner.get(); { throws IOException protected void skipUntil(TokenType stopToken) } } } skipUntil(Scanner.GT); { else } parseNotation(); { else if (token.value.equals("NOTATION")) } parseEntity(); { else if (token.value.equals("ENTITY")) } parseAttlist(); { else if (token.value.equals("ATTLIST")) } parseElement(); { if (token.value.equals("ELEMENT")) token = expect(Scanner.IDENTIFIER); { else if (token.type == Scanner.LTBANG) ad V R D : i W .
v
h
@
2
(
"
!
h g F E 4 * W E "
w
e
d
L
>
u & S R , + U K
| I ? > { z i _ 9 8 [ I } k 7 ! ~ h V U } } cs = new DTDSequence(); { else } cs = new DTDChoice(); { if (token.type == Scanner.PIPE) { if (cs == null) separator = token.type; } "Can't mix separators in a choice/sequence"); throw new IOException( { if ((separator != null) && (separator != token.type)) { (token.type == Scanner.COMMA)) if ((token.type == Scanner.PIPE) || Token token = scanner.get(); DTDItem item = parseCP(); { for (;;) DTDContainer cs = null; TokenType separator = null; { throws IOException protected DTDContainer parseChoiceSequence() } element.content = choiceSeq; } choiceSeq.cardinal = DTDCardinal.NONE; { else } choiceSeq.cardinal = DTDCardinal.ONEMANY; { else if (token.type == Scanner.PLUS) } choiceSeq.cardinal = DTDCardinal.ZEROMANY; { else if (token.type == Scanner.ASTERISK) } choiceSeq.cardinal = DTDCardinal.OPTIONAL; { if (token.type == Scanner.QUES) choiceSeq.cardinal = parseCardinality(); Token token = scanner.peek(); DTDContainer choiceSeq = parseChoiceSequence(); { throws IOException protected void parseChildren(DTDElement element) } } } token.type.name); throw new IOException("Invalid token in Mixed content type: "+ { else } mixed.add(new DTDName(token.value)); token = scanner.get(); { else if (token.type == Scanner.PIPE) } return; } mixed.cardinal = DTDCardinal.NONE; { else } mixed.cardinal = DTDCardinal.ZEROMANY; scanner.get(); { if (token.type == Scanner.ASTERISK) token = scanner.peek(); { if (token.type == Scanner.RPAREN) Token token = scanner.get(); { for (;;) element.content = mixed; scanner.get(); mixed.add(new DTDPCData()); DTDMixed mixed = new DTDMixed(); { throws IOException protected void parseMixed(DTDElement element) } } } parseChildren(element); { else if (token.type == Scanner.LPAREN) } } parseChildren(element); { else } parseMixed(element); { if (token.value.equals("#PCDATA")) { if (token.type == Scanner.IDENTIFIER) token = scanner.peek(); { else if (token.type == Scanner.LPAREN) } } element.content = new DTDAny(); { else if (token.value.equals("ANY")) } element.content = new DTDEmpty(); ad ` s a 7 % t N @ 6 0 /
|
r
E
;
p N D C { z R H -
{
q
D
:
~ c ] + * R H G ' & O 4 . l k = 3 n ` V ' r D 6
n ` 2 $ ` _ throw new IOException( { else } attr.decl = DTDDecl.IMPLIED; { else if (token.value.equals("#IMPLIED")) } attr.decl = DTDDecl.REQUIRED; { else if (token.value.equals("#REQUIRED")) } attr.defaultValue = token.value; token = scanner.get(); attr.decl = DTDDecl.FIXED; { if (token.value.equals("#FIXED")) scanner.get(); { if (token.type == Scanner.IDENTIFIER) token = scanner.peek(); } attr.type = parseEnumeration(); { else if (token.type == Scanner.LPAREN) } } attr.type = token.value; { else } attr.type = parseNotationList(); { if (token.value.equals("NOTATION")) { if (token.type == Scanner.IDENTIFIER) token = scanner.get(); element.attributes.put(token.value, attr); DTDAttribute attr = new DTDAttribute(token.value); Token token = expect(Scanner.IDENTIFIER); { throws IOException protected void parseAttdef(Scanner scanner, DTDElement element) } } token = scanner.peek(); parseAttdef(scanner, element); { while (token.type != Scanner.GT) token = scanner.peek(); } dtd.elements.put(token.value, element); element = new DTDElement(token.value); { if (element == null) DTDElement element = (DTDElement) dtd.elements.get(token.value); Token token = expect(Scanner.IDENTIFIER); { throws IOException protected void parseAttlist() } } return DTDCardinal.NONE; { else } return DTDCardinal.ONEMANY; scanner.get(); { else if (token.type == Scanner.PLUS) } return DTDCardinal.ZEROMANY; scanner.get(); { else if (token.type == Scanner.ASTERISK) } return DTDCardinal.OPTIONAL; scanner.get(); { if (token.type == Scanner.QUES) Token token = scanner.peek(); { throws IOException protected DTDCardinal parseCardinality() } return item; item.cardinal = parseCardinality(); } token.type.name); throw new IOException("Found invalid token in sequence: "+ { else } item = parseChoiceSequence(); { else if (token.type == Scanner.LPAREN) } item = new DTDName(token.value); { if (token.type == Scanner.IDENTIFIER) DTDItem item = null; Token token = scanner.get(); { throws IOException protected DTDItem parseCP() } } } token.type.name); throw new IOException("Found invalid token in sequence: "+ { else } return cs; cs.add(item); } cs = new DTDChoice(); { if (cs == null) { else if (token.type == Scanner.RPAREN) } cs.add(item); ad : W M 2 z @ ? . $
u
O
A
@
w i 8 * | v u E * $
q
c
h Z ; \ N # ^ T 7 w v 1 0
x w W V { u P O % ~ p ? z l ; : 9 DTDPublic pub = new DTDPublic(); { else if (token.value.equals("PUBLIC")) } entity.externalID = sys; sys.system = token.value; token = expect(Scanner.STRING); DTDSystem sys = new DTDSystem(); { if (token.value.equals("SYSTEM")) { else if (token.type == Scanner.IDENTIFIER) } entity.value = token.value; { if (token.type == Scanner.STRING) Token token = scanner.get(); { throws IOException protected void parseEntityDef(DTDEntity entity) } } scanner.addEntity(entity.name, entity.value); { if (entity.isParsed && (entity.value != null)) parseEntityDef(entity); entity.isParsed = isParsed; } dtd.entities.put(entity.name, entity); entity = new DTDEntity(name.value); { if (entity == null) DTDEntity entity = (DTDEntity) dtd.entities.get(name.value); } throw new IOException("Invalid entity declaration"); { else if (name.type != Scanner.IDENTIFIER) } name = expect(Scanner.IDENTIFIER); isParsed = true; { if (name.type == Scanner.PERCENT) Token name = scanner.get(); boolean isParsed = false; { throws IOException protected void parseEntity() } } scanner.get(); // eat the pipe } token.type.name); throw new IOException("Invalid token in enumeration: "+ { else if (token.type != Scanner.PIPE) } return enumeration; scanner.get(); { if (token.type == Scanner.RPAREN) token = scanner.peek(); enumeration.add(token.value); } token.type.name); throw new IOException("Invalid token in enumeration: "+ { if (token.type != Scanner.IDENTIFIER) Token token = scanner.get(); { for (;;) DTDEnumeration enumeration = new DTDEnumeration(); { throws IOException protected DTDEnumeration parseEnumeration() } } scanner.get(); // eat the pipe } token.type.name); throw new IOException("Invalid token in notation: "+ { else if (token.type != Scanner.PIPE) } return notation; scanner.get(); { if (token.type == Scanner.RPAREN) token = scanner.peek(); notation.add(token.value); } token.type.name); throw new IOException("Invalid token in notation: "+ { if (token.type != Scanner.IDENTIFIER) Token token = scanner.get(); { for (;;) DTDNotationList notation = new DTDNotationList(); { throws IOException protected DTDNotationList parseNotationList() } } attr.defaultValue = token.value; attr.decl = DTDDecl.VALUE; scanner.get(); { else if (token.type == Scanner.STRING) } } token.value); "Invalid token in attribute declaration: "+ dtdparser-1.21/source/com/wutka/dtd/DTD.java 0000644 0001750 0001750 00000005550 07515664513 020216 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
/** Represents a parsed Document Type Definition
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTD implements DTDOutput
{
/** Contains all the elements defined in the DTD */
public Hashtable elements;
/** Contains all the entities defined in the DTD */
public Hashtable entities;
/** Contains all the notations defined in the DTD */
public Hashtable notations;
/** Contains parsed DTD's for any external entity DTD declarations */
public Hashtable externalDTDs;
/** Contains all the items defined in the DTD in their original order */
public Vector items;
/** Contains the element that is most likely the root element or null
if the root element can't be determined. */
public DTDElement rootElement;
/** Creates a new DTD */
public DTD()
{
elements = new Hashtable();
entities = new Hashtable();
notations = new Hashtable();
externalDTDs = new Hashtable();
items = new Vector();
}
/** Writes the DTD to an output writer in standard DTD format (the format
* the parser normally reads).
* @param outWriter The writer where the DTD will be written
*/
public void write(PrintWriter outWriter)
throws IOException
{
Enumeration e = items.elements();
while (e.hasMoreElements())
{
DTDOutput item = (DTDOutput) e.nextElement();
item.write(outWriter);
}
}
/** Returns true if this object is equal to another */
public boolean equals(Object ob)
{
if (this == ob) return true;
if (!(ob instanceof DTD)) return false;
DTD otherDTD = (DTD) ob;
return items.equals(otherDTD.items);
}
/** Stores an array of items in the items array */
public void setItems(Object[] newItems)
{
items = new Vector(newItems.length);
for (int i=0; i < newItems.length; i++)
{
items.addElement(newItems[i]);
}
}
/** Returns the items as an array */
public Object[] getItems()
{
return items.toArray();
}
/** Stores an item in the items array */
public void setItem(Object item, int i)
{
items.setElementAt(item, i);
}
/** Retrieves an item from the items array */
public Object getItem(int i)
{
return items.elementAt(i);
}
/** Retrieves a list of items of a particular type */
public Vector getItemsByType(Class itemType)
{
Vector results = new Vector();
Enumeration e = items.elements();
while (e.hasMoreElements())
{
Object ob = e.nextElement();
if (itemType.isAssignableFrom(ob.getClass()))
{
results.addElement(ob);
}
}
return results;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDAny.java 0000644 0001750 0001750 00000001163 07515664513 020662 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents the ANY keyword in an Element's content spec
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDAny extends DTDItem
{
public DTDAny()
{
}
/** Writes "ANY" to a print writer */
public void write(PrintWriter out)
throws IOException
{
out.print("ANY");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDAny)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDAttlist.java 0000644 0001750 0001750 00000005422 07515664513 021561 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
/** Represents an ATTLIST declaration in the DTD. Although attributes are
* associated with elements, the ATTLIST is here to allow the DTD object
* to write out the DTD in roughly the original form. Because the ATTLIST
* may appear somewhere other than immediately after the ELEMENT, this object
* is used to keep track of where it is.
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDAttlist implements DTDOutput
{
/** The name of the element */
public String name;
/** The attlist's attributes */
public Vector attributes;
public DTDAttlist()
{
attributes = new Vector();
}
public DTDAttlist(String aName)
{
name = aName;
attributes = new Vector();
}
/** Writes out an ATTLIST declaration */
public void write(PrintWriter out)
throws IOException
{
out.print("");
}
}
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDAttlist)) return false;
DTDAttlist other = (DTDAttlist) ob;
if ((name == null) && (other.name != null)) return false;
if ((name != null) && !name.equals(other.name)) return false;
return attributes.equals(other.attributes);
}
/** Returns the entity name of this attlist */
public String getName()
{
return name;
}
/** Sets the entity name of this attlist */
public void setName(String aName)
{
name = aName;
}
/** Returns the attributes in this list */
public DTDAttribute[] getAttribute()
{
DTDAttribute attrs[] = new DTDAttribute[attributes.size()];
attributes.copyInto(attrs);
return attrs;
}
/** Sets the list of attributes */
public void setAttribute(DTDAttribute[] attrs)
{
attributes = new Vector(attrs.length);
for (int i=0; i < attrs.length; i++)
{
attributes.addElement(attrs[i]);
}
}
/** Returns a specific attribute from the list */
public DTDAttribute getAttribute(int i)
{
return (DTDAttribute) attributes.elementAt(i);
}
/** Sets a specific attribute in the list */
public void setAttribute(DTDAttribute attr, int i)
{
attributes.setElementAt(attr, i);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDAttribute.java 0000644 0001750 0001750 00000007223 07515664513 022101 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents a DTD Attribute in an ATTLIST declaration
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDAttribute implements DTDOutput
{
/** The name of the attribute */
public String name;
/** The type of the attribute (either String, DTDEnumeration or
DTDNotationList) */
public Object type;
/** The attribute's declaration (required, fixed, implied) */
public DTDDecl decl;
/** The attribute's default value (null if not declared) */
public String defaultValue;
public DTDAttribute()
{
}
public DTDAttribute(String aName)
{
name = aName;
}
/** Writes this attribute to an output stream */
public void write(PrintWriter out)
throws IOException
{
out.print(name+" ");
if (type instanceof String)
{
out.print(type);
}
else if (type instanceof DTDEnumeration)
{
DTDEnumeration dtdEnum = (DTDEnumeration) type;
dtdEnum.write(out);
}
else if (type instanceof DTDNotationList)
{
DTDNotationList dtdnl = (DTDNotationList) type;
dtdnl.write(out);
}
if (decl != null)
{
decl.write(out);
}
if (defaultValue != null)
{
out.print(" \"");
out.print(defaultValue);
out.print("\"");
}
//out.println(">"); Bug!
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDAttribute)) return false;
DTDAttribute other = (DTDAttribute) ob;
if (name == null)
{
if (other.name != null) return false;
}
else
{
if (!name.equals(other.name)) return false;
}
if (type == null)
{
if (other.type != null) return false;
}
else
{
if (!type.equals(other.type)) return false;
}
if (decl == null)
{
if (other.decl != null) return false;
}
else
{
if (!decl.equals(other.decl)) return false;
}
if (defaultValue == null)
{
if (other.defaultValue != null) return false;
}
else
{
if (!defaultValue.equals(other.defaultValue)) return false;
}
return true;
}
/** Sets the name of the attribute */
public void setName(String aName)
{
name = aName;
}
/** Returns the attribute name */
public String getName()
{
return name;
}
/** Sets the type of the attribute */
public void setType(Object aType)
{
if (!(aType instanceof String) &&
!(aType instanceof DTDEnumeration) &&
!(aType instanceof DTDNotationList))
{
throw new IllegalArgumentException(
"Must be String, DTDEnumeration or DTDNotationList");
}
type = aType;
}
/** Gets the type of the attribute */
public Object getType()
{
return type;
}
/** Sets the declaration (fixed, required, implied) */
public void setDecl(DTDDecl aDecl)
{
decl = aDecl;
}
/** Returns the declaration */
public DTDDecl getDecl()
{
return decl;
}
/** Sets the default value */
public void setDefaultValue(String aDefaultValue)
{
defaultValue = aDefaultValue;
}
/** Returns the default value */
public String getDefaultValue()
{
return defaultValue;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDCardinal.java 0000644 0001750 0001750 00000003573 07515664513 021657 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents the various cardinality values for a DTD item.
*
*
NONE indicates no cardinality
*
OPTIONAL indicates an optional value (specified by ?)
*
ZEROMANY indicates zero-to-many values (specified by *)
*
ONEMANY indicates an one-to-many values (specified by +)
*
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDCardinal implements DTDOutput
{
/** Indicates no cardinality (implies a single object) */
public static final DTDCardinal NONE = new DTDCardinal(0, "NONE");
/** Indicates that an item is optional (zero-to-one) */
public static final DTDCardinal OPTIONAL = new DTDCardinal(1, "OPTIONAL");
/** Indicates that there can be zero-to-many occurrances of an item */
public static final DTDCardinal ZEROMANY = new DTDCardinal(2, "ZEROMANY");
/** Indicates that there can be one-to-many occurrances of an item */
public static final DTDCardinal ONEMANY = new DTDCardinal(3, "ONEMANY");
public int type;
public String name;
public DTDCardinal(int aType, String aName)
{
type = aType;
name = aName;
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDCardinal)) return false;
DTDCardinal other = (DTDCardinal) ob;
if (other.type == type) return true;
return false;
}
/** Writes the notation for this cardinality value */
public void write(PrintWriter out)
throws IOException
{
if (this == NONE) return;
if (this == OPTIONAL)
{
out.print("?");
}
else if (this == ZEROMANY)
{
out.print("*");
}
else if (this == ONEMANY)
{
out.print("+");
}
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDChoice.java 0000644 0001750 0001750 00000002012 07515664513 021317 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
/** Represents a choice of items.
* A choice in a DTD looks like (option1 | option2 | option3)
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDChoice extends DTDContainer
{
public DTDChoice()
{
}
/** Writes out the possible choices to a PrintWriter */
public void write(PrintWriter out)
throws IOException
{
out.print("(");
Enumeration e = getItemsVec().elements();
boolean isFirst = true;
while (e.hasMoreElements())
{
if (!isFirst) out.print(" | ");
isFirst = false;
DTDItem item = (DTDItem) e.nextElement();
item.write(out);
}
out.print(")");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDChoice)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDComment.java 0000644 0001750 0001750 00000002214 07515664513 021533 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents a comment in the DTD
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDComment implements DTDOutput
{
/** The comment text */
public String text;
public DTDComment()
{
}
public DTDComment(String theText)
{
text = theText;
}
public String toString()
{
return text;
}
public void write(PrintWriter out)
throws IOException
{
out.print("");
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDComment)) return false;
DTDComment other = (DTDComment) ob;
if ((text == null) && (other.text != null)) return false;
if ((text != null) && !text.equals(other.text)) return false;
return true;
}
/** Sets the comment text */
public void setText(String theText)
{
text = theText;
}
/** Returns the comment text */
public String getText()
{
return text;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDContainer.java 0000644 0001750 0001750 00000004072 07515664513 022057 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
/** Represents an item that may contain other items (such as a
* DTDChoice or a DTDSequence)
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public abstract class DTDContainer extends DTDItem
{
protected Vector items;
/** Creates a new DTDContainer */
public DTDContainer()
{
items = new Vector();
}
/** Adds an element to the container */
public void add(DTDItem item)
{
items.addElement(item);
}
/** Removes an element from the container */
public void remove(DTDItem item)
{
items.removeElement(item);
}
/** Returns the elements as a vector (not a clone!) */
public Vector getItemsVec()
{
return items;
}
/** Returns the elements as an array of items */
public DTDItem[] getItems()
{
DTDItem[] retval = new DTDItem[items.size()];
items.copyInto(retval);
return retval;
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDContainer)) return false;
if (!super.equals(ob)) return false;
DTDContainer other = (DTDContainer) ob;
return items.equals(other.items);
}
/** Stores items in the container */
public void setItem(DTDItem[] newItems)
{
items = new Vector(newItems.length);
for (int i=0; i < newItems.length; i++)
{
items.addElement(newItems[i]);
}
}
/** Retrieves the items in the container */
public DTDItem[] getItem()
{
DTDItem[] retval = new DTDItem[items.size()];
items.copyInto(retval);
return retval;
}
/** Stores an item in the container */
public void setItem(DTDItem anItem, int i)
{
items.setElementAt(anItem, i);
}
/** Retrieves an item from the container */
public DTDItem getItem(int i)
{
return (DTDItem) items.elementAt(i);
}
public abstract void write(PrintWriter out)
throws IOException;
}
dtdparser-1.21/source/com/wutka/dtd/DTDDecl.java 0000644 0001750 0001750 00000002511 07515664513 021000 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents the possible values for an attribute declaration
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDDecl implements DTDOutput
{
public static final DTDDecl FIXED = new DTDDecl(0, "FIXED");
public static final DTDDecl REQUIRED = new DTDDecl(1, "REQUIRED");
public static final DTDDecl IMPLIED = new DTDDecl(2, "IMPLIED");
public static final DTDDecl VALUE = new DTDDecl(3, "VALUE");
public int type;
public String name;
public DTDDecl(int aType, String aName)
{
type = aType;
name = aName;
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDDecl)) return false;
DTDDecl other = (DTDDecl) ob;
if (other.type == type) return true;
return false;
}
public void write(PrintWriter out)
throws IOException
{
if (this == FIXED)
{
out.print(" #FIXED");
}
else if (this == REQUIRED)
{
out.print(" #REQUIRED");
}
else if (this == IMPLIED)
{
out.print(" #IMPLIED");
}
// Don't do anything for value since there is no associated DTD keyword
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDElement.java 0000644 0001750 0001750 00000006240 07515664513 021525 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
/** Represents an element defined with the ELEMENT DTD tag
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDElement implements DTDOutput
{
/** The name of the element */
public String name;
/** The element's attributes */
public Hashtable attributes;
/** The element's content */
public DTDItem content;
public DTDElement()
{
attributes = new Hashtable();
}
public DTDElement(String aName)
{
name = aName;
attributes = new Hashtable();
}
/** Writes out an element declaration and an attlist declaration (if necessary)
for this element */
public void write(PrintWriter out)
throws IOException
{
out.print("");
out.println();
/*
if (attributes.size() > 0)
{
out.print("");
}
}
*/
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDElement)) return false;
DTDElement other = (DTDElement) ob;
if (name == null)
{
if (other.name != null) return false;
}
else
{
if (!name.equals(other.name)) return false;
}
if (attributes == null)
{
if (other.attributes != null) return false;
}
else
{
if (!attributes.equals(other.attributes)) return false;
}
if (content == null)
{
if (other.content != null) return false;
}
else
{
if (!content.equals(other.content)) return false;
}
return true;
}
/** Sets the name of this element */
public void setName(String aName)
{
name = aName;
}
/** Returns the name of this element */
public String getName()
{
return name;
}
/** Stores an attribute in this element */
public void setAttribute(String attrName, DTDAttribute attr)
{
attributes.put(attrName, attr);
}
/** Gets an attribute for this element */
public DTDAttribute getAttribute(String attrName)
{
return (DTDAttribute) attributes.get(attrName);
}
/** Sets the content type of this element */
public void setContent(DTDItem theContent)
{
content = theContent;
}
/** Returns the content type of this element */
public DTDItem getContent()
{
return content;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDEmpty.java 0000644 0001750 0001750 00000001174 07515664513 021233 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents the EMPTY keyword in an Element's content spec
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDEmpty extends DTDItem
{
public DTDEmpty()
{
}
/** Writes out the keyword "EMPTY" */
public void write(PrintWriter out)
throws IOException
{
out.print("EMPTY");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDEmpty)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDEntity.java 0000644 0001750 0001750 00000012730 07521626376 021413 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.net.*;
/** Represents an Entity defined in a DTD
*
* @author Mark Wutka
* @version $Revision: 1.18 $ $Date: 2002/07/31 00:19:10 $ by $Author: wutka $
*/
public class DTDEntity implements DTDOutput
{
public String name;
public boolean isParsed;
public String value;
public DTDExternalID externalID;
public String ndata;
public Object defaultLocation;
public DTDEntity()
{
}
public DTDEntity(String aName)
{
name = aName;
}
public DTDEntity(String aName, Object aDefaultLocation)
{
name = aName;
defaultLocation = aDefaultLocation;
}
/** Writes out an entity declaration for this entity */
public void write(PrintWriter out)
throws IOException
{
out.print("= 0) quoteChar='\'';
out.print(quoteChar);
out.print(value);
out.print(quoteChar);
}
else
{
externalID.write(out);
if (ndata != null)
{
out.print(" NDATA ");
out.print(ndata);
}
}
out.println(">");
}
public String getExternalId()
{
return(externalID.system);
}
public Reader getReader()
throws IOException
{
// MAW Ver 1.19 - Added check for externalID == null
if (externalID == null)
{
return null;
}
Reader rd = getReader(externalID.system);
return rd;
}
public Reader getReader(String entityName)
{
try
{
if (defaultLocation != null)
{
if (defaultLocation instanceof File)
{
File loc = (File) defaultLocation;
BufferedReader in = new BufferedReader(
new FileReader(new File(loc, entityName)));
return in;
}
else if (defaultLocation instanceof URL)
{
// MAW Version 1.17
// Changed to construct new URL based on default
// location plus the entity name just like is done
// with the File-based name. This allows parsing of
// a URL-based DTD file that references other files either
// relatively or absolutely.
URL url = new URL((URL) defaultLocation, entityName);
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
return in;
}
}
BufferedReader in = new BufferedReader(
new FileReader(entityName));
return in;
}
catch (Exception ignore)
{
}
try
{
URL url = new URL(entityName);
InputStream inStream = url.openStream();
BufferedReader in = new BufferedReader(
new InputStreamReader(inStream));
return in;
}
catch (Exception ignore)
{
}
return null;
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDEntity)) return false;
DTDEntity other = (DTDEntity) ob;
if (name == null)
{
if (other.name != null) return false;
}
else
{
if (!name.equals(other.name)) return false;
}
if (isParsed != other.isParsed) return false;
if (value == null)
{
if (other.value != null) return false;
}
else
{
if (!value.equals(other.value)) return false;
}
if (externalID == null)
{
if (other.externalID != null) return false;
}
else
{
if (!externalID.equals(other.externalID)) return false;
}
if (ndata == null)
{
if (other.ndata != null) return false;
}
else
{
if (!ndata.equals(other.ndata)) return false;
}
return true;
}
/** Sets the name of this entity */
public void setName(String aName)
{
name = aName;
}
/** Returns the name of this entity */
public String getName()
{
return name;
}
/** Sets the isParsed flag */
public void setIsParsed(boolean flag)
{
isParsed = flag;
}
/** Returns the isParsed flag */
public boolean isParsed()
{
return isParsed;
}
/** Sets the entity value */
public void setValue(String aValue)
{
value = aValue;
}
/** Returns the entity value */
public String getValue()
{
return value;
}
/** Sets the external ID for the entity */
public void setExternalID(DTDExternalID anExternalID)
{
externalID = anExternalID;
}
/** Returns the external ID for the entity */
public DTDExternalID getExternalID()
{
return externalID;
}
/** Sets the entity ndata */
public void setNdata(String anNdata)
{
ndata = anNdata;
}
/** Returns the entity ndata */
public String getNdata()
{
return ndata;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDEnumeration.java 0000644 0001750 0001750 00000004334 07515664513 022424 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
/** Represents an enumeration of attribute values
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDEnumeration implements DTDOutput
{
protected Vector items;
/** Creates a new enumeration */
public DTDEnumeration()
{
items = new Vector();
}
/** Adds a new value to the list of values */
public void add(String item)
{
items.addElement(item);
}
/** Removes a value from the list of values */
public void remove(String item)
{
items.removeElement(item);
}
/** Returns the values as an array */
public String[] getItems()
{
String[] retval = new String[items.size()];
items.copyInto(retval);
return retval;
}
/** Returns the values as a vector (not a clone!) */
public Vector getItemsVec()
{
return items;
}
/** Writes out a declaration for this enumeration */
public void write(PrintWriter out)
throws IOException
{
out.print("( ");
Enumeration e = getItemsVec().elements();
boolean isFirst = true;
while (e.hasMoreElements())
{
if (!isFirst) out.print(" | ");
isFirst = false;
out.print(e.nextElement());
}
out.print(")");
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDEnumeration)) return false;
DTDEnumeration other = (DTDEnumeration) ob;
return items.equals(other.items);
}
/** Returns the items in the enumeration */
public String[] getItem() { return getItems(); }
/** Sets the items in the enumeration */
public void setItem(String[] newItems)
{
items = new Vector(newItems.length);
for (int i=0; i < newItems.length; i++)
{
items.addElement(newItems[i]);
}
}
/** Stores an item in the enumeration */
public void setItem(String item, int i)
{
items.setElementAt(item, i);
}
/** Retrieves an item from the enumeration */
public String getItem(int i)
{
return (String) items.elementAt(i);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDExternalID.java 0000644 0001750 0001750 00000002073 07515664513 022133 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents an external ID in an entity declaration
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public abstract class DTDExternalID implements DTDOutput
{
public String system;
public DTDExternalID()
{
}
/** Writes out a declaration for this external ID */
public abstract void write(PrintWriter out)
throws IOException;
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDExternalID)) return false;
DTDExternalID other = (DTDExternalID) ob;
if (system == null)
{
if (other.system != null) return false;
}
else
{
if (!system.equals(other.system)) return false;
}
return true;
}
/** Sets the system ID */
public void setSystem(String aSystem)
{
system = aSystem;
}
/** Retrieves the system ID */
public String getSystem()
{
return system;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDItem.java 0000644 0001750 0001750 00000002347 07515664513 021036 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents any item in the DTD
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public abstract class DTDItem implements DTDOutput
{
/** Indicates how often the item may occur */
public DTDCardinal cardinal;
public DTDItem()
{
cardinal = DTDCardinal.NONE;
}
public DTDItem(DTDCardinal aCardinal)
{
cardinal = aCardinal;
}
/** Writes out a declaration for this item */
public abstract void write(PrintWriter out)
throws IOException;
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDItem)) return false;
DTDItem other = (DTDItem) ob;
if (cardinal == null)
{
if (other.cardinal != null) return false;
}
else
{
if (!cardinal.equals(other.cardinal)) return false;
}
return true;
}
/** Sets the cardinality of the item */
public void setCardinal(DTDCardinal aCardinal)
{
cardinal = aCardinal;
}
/** Retrieves the cardinality of the item */
public DTDCardinal getCardinal()
{
return cardinal;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDMixed.java 0000644 0001750 0001750 00000002123 07515664513 021176 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
/** Represents a mixed Element content (PCDATA + choice/sequence).
* Mixed Element can contain #PCDATA, or it can contain
* #PCDATA followed by a list of pipe-separated names.
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDMixed extends DTDContainer
{
public DTDMixed()
{
}
/** Writes out a declaration for mixed content */
public void write(PrintWriter out)
throws IOException
{
out.print("(");
Enumeration e = getItemsVec().elements();
boolean isFirst = true;
while (e.hasMoreElements())
{
if (!isFirst) out.print(" | ");
isFirst = false;
DTDItem item = (DTDItem) e.nextElement();
item.write(out);
}
out.print(")");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDMixed)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDName.java 0000644 0001750 0001750 00000002222 07515664513 021010 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents a named item in the DTD
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDName extends DTDItem
{
public String value;
public DTDName()
{
}
public DTDName(String aValue)
{
value = aValue;
}
/** Writes out the value of this name */
public void write(PrintWriter out)
throws IOException
{
out.print(value);
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDName)) return false;
if (!super.equals(ob)) return false;
DTDName other = (DTDName) ob;
if (value == null)
{
if (other.value != null) return false;
}
else
{
if (!value.equals(other.value)) return false;
}
return true;
}
/** Sets the name value */
public void setValue(String aValue)
{
value = aValue;
}
/** Retrieves the name value */
public String getValue()
{
return value;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDNotation.java 0000644 0001750 0001750 00000003316 07515664513 021730 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents a Notation defined in a DTD
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDNotation implements DTDOutput
{
public String name;
public DTDExternalID externalID;
public DTDNotation()
{
}
public DTDNotation(String aName)
{
name = aName;
}
/** Writes out a declaration for this notation */
public void write(PrintWriter out)
throws IOException
{
out.print("");
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDNotation)) return false;
DTDNotation other = (DTDNotation) ob;
if (name == null)
{
if (other.name != null) return false;
}
else
{
if (!name.equals(other.name)) return false;
}
if (externalID == null)
{
if (other.externalID != null) return false;
}
else
{
if (!externalID.equals(other.externalID)) return false;
}
return true;
}
/** Sets the notation name */
public void setName(String aName)
{
name = aName;
}
/** Retrieves the notation name */
public String getName()
{
return name;
}
/** Sets the external ID */
public void setExternalID(DTDExternalID theExternalID)
{
externalID = theExternalID;
}
/** Retrieves the external ID */
public DTDExternalID getExternalID()
{
return externalID;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDNotationList.java 0000644 0001750 0001750 00000004415 07515664513 022565 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
/** Represents a notation declaration for an attribute
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDNotationList implements DTDOutput
{
protected Vector items;
/** Creates a new notation */
public DTDNotationList()
{
items = new Vector();
}
/** Adds a item to the list of notation values */
public void add(String item)
{
items.addElement(item);
}
/** Removes an item from the list of notation values */
public void remove(String item)
{
items.removeElement(item);
}
/** Returns the list of notation values as an array */
public String[] getItems()
{
String[] retval = new String[items.size()];
items.copyInto(retval);
return retval;
}
/** Returns the list of notation values as a vector */
public Vector getItemsVec()
{
return items;
}
/** Writes a declaration for this notation */
public void write(PrintWriter out)
throws IOException
{
out.print("NOTATION ( ");
Enumeration e = getItemsVec().elements();
boolean isFirst = true;
while (e.hasMoreElements())
{
if (!isFirst) out.print(" | ");
isFirst = false;
out.print(e.nextElement());
}
out.print(")");
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDNotationList)) return false;
DTDNotationList other = (DTDNotationList) ob;
return items.equals(other.items);
}
/** Returns the items in the notation list */
public String[] getItem() { return getItems(); }
/** Sets the items in the notation list */
public void setItem(String[] newItems)
{
items = new Vector(newItems.length);
for (int i=0; i < newItems.length; i++)
{
items.addElement(newItems[i]);
}
}
/** Stores an item in the notation list */
public void setItem(String item, int i)
{
items.setElementAt(item, i);
}
/** Retrieves an item from the notation list */
public String getItem(int i)
{
return (String) items.elementAt(i);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDOutput.java 0000644 0001750 0001750 00000000472 07515664513 021435 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Defines the method used for writing DTD information to a PrintWriter
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public interface DTDOutput
{
public void write(PrintWriter out) throws IOException;
}
dtdparser-1.21/source/com/wutka/dtd/DTDPCData.java 0000644 0001750 0001750 00000001204 07515664513 021223 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents the #PCDATA keyword in an Element's content spec
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDPCData extends DTDItem
{
public DTDPCData()
{
}
/** Writes out the #PCDATA keyword */
public void write(PrintWriter out)
throws IOException
{
out.print("#PCDATA");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDPCData)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDParseException.java 0000644 0001750 0001750 00000002027 07515664513 023064 0 ustar arnaud arnaud package com.wutka.dtd;
public class DTDParseException extends java.io.IOException
{
public String uriID = "";
public int lineNumber;
public int column;
public DTDParseException()
{
lineNumber=-1;
column=-1;
}
public DTDParseException(String message)
{
super(message);
lineNumber=-1;
column=-1;
}
public DTDParseException(String message, int line, int col)
{
super("At line "+line+", column "+col+": "+message);
lineNumber = line;
column = col;
}
public DTDParseException(String id, String message, int line, int col)
{
super(((null != id && id.length() > 0) ? "URI " + id + " at " : "At ")
+ "line " + line + ", column " + col + ": " + message);
if (null != id)
uriID = id;
lineNumber = line;
column = col;
}
public String getId() { return(uriID); }
public int getLineNumber() { return lineNumber; }
public int getColumn() { return column; }
}
dtdparser-1.21/source/com/wutka/dtd/DTDParser.java 0000644 0001750 0001750 00000070571 07546314657 021405 0 ustar arnaud arnaud package com.wutka.dtd;
import java.util.*;
import java.io.*;
import java.net.*;
/** Parses a DTD file and returns a DTD object
*
* @author Mark Wutka
* @version $Revision: 1.19 $ $Date: 2002/10/01 12:48:47 $ by $Author: wutka $
*/
public class DTDParser implements EntityExpansion
{
protected Scanner scanner;
protected DTD dtd;
protected Object defaultLocation;
/** Creates a parser that will read from the specified Reader object */
public DTDParser(Reader in)
{
scanner = new Scanner(in, false, this);
dtd = new DTD();
}
/** Creates a parser that will read from the specified Reader object
* @param in The input stream to read
* @param trace True if the parser should print out tokens as it reads them
* (used for debugging the parser)
*/
public DTDParser(Reader in, boolean trace)
{
scanner = new Scanner(in, trace, this);
dtd = new DTD();
}
/** Creates a parser that will read from the specified File object */
public DTDParser(File in)
throws IOException
{
defaultLocation = in.getParentFile();
scanner = new Scanner(new BufferedReader(new FileReader(in)),
false, this);
dtd = new DTD();
}
/** Creates a parser that will read from the specified File object
* @param in The file to read
* @param trace True if the parser should print out tokens as it reads them
* (used for debugging the parser)
*/
public DTDParser(File in, boolean trace)
throws IOException
{
defaultLocation = in.getParentFile();
scanner = new Scanner(new BufferedReader(new FileReader(in)),
trace, this);
dtd = new DTD();
}
/** Creates a parser that will read from the specified URL object */
public DTDParser(URL in)
throws IOException
{
//LAM: we need to set the defaultLocation to the directory where
//the dtd is found so that we don't run into problems parsing any
//relative external files referenced by the dtd.
String file = in.getFile();
defaultLocation = new URL(in.getProtocol(), in.getHost(), in.getPort(), file.substring(0, file.lastIndexOf('/') + 1));
scanner = new Scanner(new BufferedReader(
new InputStreamReader(in.openStream())), false, this);
dtd = new DTD();
}
/** Creates a parser that will read from the specified URL object
* @param in The URL to read
* @param trace True if the parser should print out tokens as it reads them
* (used for debugging the parser)
*/
public DTDParser(URL in, boolean trace)
throws IOException
{
//LAM: we need to set the defaultLocation to the directory where
//the dtd is found so that we don't run into problems parsing any
//relative external files referenced by the dtd.
String file = in.getFile();
defaultLocation = new URL(in.getProtocol(), in.getHost(), in.getPort(), file.substring(0, file.lastIndexOf('/') + 1));
scanner = new Scanner(new BufferedReader(
new InputStreamReader(in.openStream())), trace, this);
dtd = new DTD();
}
/** Parses the DTD file and returns a DTD object describing the DTD.
This invocation of parse does not try to guess the root element
(for efficiency reasons) */
public DTD parse()
throws IOException
{
return parse(false);
}
/** Parses the DTD file and returns a DTD object describing the DTD.
* @param guessRootElement If true, tells the parser to try to guess the
root element of the document by process of elimination
*/
public DTD parse(boolean guessRootElement)
throws IOException
{
Token token;
for (;;)
{
token = scanner.peek();
if (token.type == Scanner.EOF) break;
parseTopLevelElement();
}
if (guessRootElement)
{
Hashtable roots = new Hashtable();
Enumeration e = dtd.elements.elements();
while (e.hasMoreElements())
{
DTDElement element = (DTDElement) e.nextElement();
roots.put(element.name, element);
}
e = dtd.elements.elements();
while (e.hasMoreElements())
{
DTDElement element = (DTDElement) e.nextElement();
if (!(element.content instanceof DTDContainer)) continue;
Enumeration items = ((DTDContainer) element.content).
getItemsVec(). elements();
while (items.hasMoreElements())
{
removeElements(roots, dtd, (DTDItem) items.nextElement());
}
}
if (roots.size() == 1)
{
e = roots.elements();
dtd.rootElement = (DTDElement) e.nextElement();
}
else
{
dtd.rootElement = null;
}
}
else
{
dtd.rootElement = null;
}
return dtd;
}
protected void removeElements(Hashtable h, DTD dtd, DTDItem item)
{
if (item instanceof DTDName)
{
h.remove(((DTDName) item).value);
}
else if (item instanceof DTDContainer)
{
Enumeration e = ((DTDContainer) item).getItemsVec().elements();
while (e.hasMoreElements())
{
removeElements(h, dtd, (DTDItem) e.nextElement());
}
}
}
protected void parseTopLevelElement()
throws IOException
{
Token token = scanner.get();
// Is xxx ?> even valid in a DTD? I'll ignore it just in case it's there
if (token.type == Scanner.LTQUES)
{
StringBuffer textBuffer = new StringBuffer();
for (;;)
{
String text = scanner.getUntil('?');
textBuffer.append(text);
token = scanner.peek();
if (token.type == Scanner.GT)
{
scanner.get();
break;
}
textBuffer.append('?');
}
DTDProcessingInstruction instruct =
new DTDProcessingInstruction(textBuffer.toString());
dtd.items.addElement(instruct);
return;
}
else if (token.type == Scanner.CONDITIONAL)
{
token = expect(Scanner.IDENTIFIER);
if (token.value.equals("IGNORE"))
{
scanner.skipConditional();
}
else
{
if (token.value.equals("INCLUDE"))
{
scanner.skipUntil('[');
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in conditional: "+token.value,
scanner.getLineNumber(), scanner.getColumn());
}
}
}
else if (token.type == Scanner.ENDCONDITIONAL)
{
// Don't need to do anything for this token
}
else if (token.type == Scanner.COMMENT)
{
dtd.items.addElement(
new DTDComment(token.value));
}
else if (token.type == Scanner.LTBANG)
{
token = expect(Scanner.IDENTIFIER);
if (token.value.equals("ELEMENT"))
{
parseElement();
}
else if (token.value.equals("ATTLIST"))
{
parseAttlist();
}
else if (token.value.equals("ENTITY"))
{
parseEntity();
}
else if (token.value.equals("NOTATION"))
{
parseNotation();
}
else
{
skipUntil(Scanner.GT);
}
}
else
{
// MAW Version 1.17
// Previously, the parser would skip over unexpected tokens at the
// upper level. Some invalid DTDs would still show up as valid.
throw new DTDParseException(scanner.getUriId(),
"Unexpected token: "+ token.type.name+"("+token.value+")",
scanner.getLineNumber(), scanner.getColumn());
}
}
protected void skipUntil(TokenType stopToken)
throws IOException
{
Token token = scanner.get();
while (token.type != stopToken)
{
token = scanner.get();
}
}
protected Token expect(TokenType expected)
throws IOException
{
Token token = scanner.get();
if (token.type != expected)
{
if (token.value == null)
{
throw new DTDParseException(scanner.getUriId(),
"Expected "+expected.name+" instead of "+token.type.name,
scanner.getLineNumber(), scanner.getColumn());
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Expected "+expected.name+
" instead of "+ token.type.name+"("+token.value+")",
scanner.getLineNumber(), scanner.getColumn());
}
}
return token;
}
protected void parseElement()
throws IOException
{
Token name = expect(Scanner.IDENTIFIER);
DTDElement element = (DTDElement) dtd.elements.get(name.value);
if (element == null)
{
element = new DTDElement(name.value);
dtd.elements.put(element.name, element);
}
else if (element.content != null)
{
// 070501 MAW: Since the ATTLIST tag can also cause an element to be created,
// only throw this exception if the element has content defined, which
// won't happen when you just create an ATTLIST. Thanks to
// Jags Krishnamurthy of Object Edge for pointing out this problem -
// originally the parser would let you define an element more than once.
throw new DTDParseException(scanner.getUriId(),
"Found second definition of element: "+name.value,
scanner.getLineNumber(), scanner.getColumn());
}
dtd.items.addElement(element);
parseContentSpec(scanner, element);
expect(Scanner.GT);
}
protected void parseContentSpec(Scanner scanner, DTDElement element)
throws IOException
{
Token token = scanner.get();
if (token.type == Scanner.IDENTIFIER)
{
if (token.value.equals("EMPTY"))
{
element.content = new DTDEmpty();
}
else if (token.value.equals("ANY"))
{
element.content = new DTDAny();
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in entity content spec "+
token.value,
scanner.getLineNumber(), scanner.getColumn());
}
}
else if (token.type == Scanner.LPAREN)
{
token = scanner.peek();
if (token.type == Scanner.IDENTIFIER)
{
if (token.value.equals("#PCDATA"))
{
parseMixed(element);
}
else
{
parseChildren(element);
}
}
else if (token.type == Scanner.LPAREN)
{
parseChildren(element);
}
}
}
protected void parseMixed(DTDElement element)
throws IOException
{
// MAW Version 1.19
// Keep track of whether the mixed is #PCDATA only
// Don't allow * after (#PCDATA), but allow after
// (#PCDATA|foo|bar|baz)*
boolean isPcdataOnly = true;
DTDMixed mixed = new DTDMixed();
mixed.add(new DTDPCData());
scanner.get();
element.content = mixed;
for (;;)
{
Token token = scanner.get();
if (token.type == Scanner.RPAREN)
{
token = scanner.peek();
if (token.type == Scanner.ASTERISK)
{
scanner.get();
mixed.cardinal = DTDCardinal.ZEROMANY;
}
else
{
if (!isPcdataOnly)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in Mixed content type, '*' required after (#PCDATA|xx ...): "+
token.type.name, scanner.getLineNumber(), scanner.getColumn());
}
mixed.cardinal = DTDCardinal.NONE;
}
return;
}
else if (token.type == Scanner.PIPE)
{
token = scanner.get();
mixed.add(new DTDName(token.value));
// MAW Ver. 1.19
isPcdataOnly = false;
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in Mixed content type: "+
token.type.name, scanner.getLineNumber(), scanner.getColumn());
}
}
}
protected void parseChildren(DTDElement element)
throws IOException
{
DTDContainer choiceSeq = parseChoiceSequence();
Token token = scanner.peek();
choiceSeq.cardinal = parseCardinality();
if (token.type == Scanner.QUES)
{
choiceSeq.cardinal = DTDCardinal.OPTIONAL;
}
else if (token.type == Scanner.ASTERISK)
{
choiceSeq.cardinal = DTDCardinal.ZEROMANY;
}
else if (token.type == Scanner.PLUS)
{
choiceSeq.cardinal = DTDCardinal.ONEMANY;
}
else
{
choiceSeq.cardinal = DTDCardinal.NONE;
}
element.content = choiceSeq;
}
protected DTDContainer parseChoiceSequence()
throws IOException
{
TokenType separator = null;
DTDContainer cs = null;
for (;;)
{
DTDItem item = parseCP();
Token token = scanner.get();
if ((token.type == Scanner.PIPE) ||
(token.type == Scanner.COMMA))
{
if ((separator != null) && (separator != token.type))
{
throw new DTDParseException(scanner.getUriId(),
"Can't mix separators in a choice/sequence",
scanner.getLineNumber(), scanner.getColumn());
}
separator = token.type;
if (cs == null)
{
if (token.type == Scanner.PIPE)
{
cs = new DTDChoice();
}
else
{
cs = new DTDSequence();
}
}
cs.add(item);
}
else if (token.type == Scanner.RPAREN)
{
if (cs == null)
{
cs = new DTDSequence();
}
cs.add(item);
return cs;
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Found invalid token in sequence: "+
token.type.name, scanner.getLineNumber(), scanner.getColumn());
}
}
}
protected DTDItem parseCP()
throws IOException
{
Token token = scanner.get();
DTDItem item = null;
if (token.type == Scanner.IDENTIFIER)
{
item = new DTDName(token.value);
}
else if (token.type == Scanner.LPAREN)
{
item = parseChoiceSequence();
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Found invalid token in sequence: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
item.cardinal = parseCardinality();
return item;
}
protected DTDCardinal parseCardinality()
throws IOException
{
Token token = scanner.peek();
if (token.type == Scanner.QUES)
{
scanner.get();
return DTDCardinal.OPTIONAL;
}
else if (token.type == Scanner.ASTERISK)
{
scanner.get();
return DTDCardinal.ZEROMANY;
}
else if (token.type == Scanner.PLUS)
{
scanner.get();
return DTDCardinal.ONEMANY;
}
else
{
return DTDCardinal.NONE;
}
}
protected void parseAttlist()
throws IOException
{
Token token = expect(Scanner.IDENTIFIER);
DTDElement element = (DTDElement) dtd.elements.get(token.value);
DTDAttlist attlist = new DTDAttlist(token.value);
dtd.items.addElement(attlist);
if (element == null)
{
element = new DTDElement(token.value);
dtd.elements.put(token.value, element);
}
token = scanner.peek();
while (token.type != Scanner.GT)
{
parseAttdef(scanner, element, attlist);
token = scanner.peek();
}
// MAW Version 1.17
// Prior to this version, the parser didn't actually consume the > at the
// end of the ATTLIST definition. Because the parser ignored unexpected tokens
// at the top level, it was ignoring the >. In parsing DOCBOOK, however, there
// were two unexpected tokens, bringing this error to light.
expect(Scanner.GT);
}
protected void parseAttdef(Scanner scanner, DTDElement element,
DTDAttlist attlist)
throws IOException
{
Token token = expect(Scanner.IDENTIFIER);
DTDAttribute attr = new DTDAttribute(token.value);
attlist.attributes.addElement(attr);
element.attributes.put(token.value, attr);
token = scanner.get();
if (token.type == Scanner.IDENTIFIER)
{
if (token.value.equals("NOTATION"))
{
attr.type = parseNotationList();
}
else
{
attr.type = token.value;
}
}
else if (token.type == Scanner.LPAREN)
{
attr.type = parseEnumeration();
}
token = scanner.peek();
if (token.type == Scanner.IDENTIFIER)
{
scanner.get();
if (token.value.equals("#FIXED"))
{
attr.decl = DTDDecl.FIXED;
token = scanner.get();
attr.defaultValue = token.value;
}
else if (token.value.equals("#REQUIRED"))
{
attr.decl = DTDDecl.REQUIRED;
}
else if (token.value.equals("#IMPLIED"))
{
attr.decl = DTDDecl.IMPLIED;
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in attribute declaration: "+
token.value, scanner.getLineNumber(), scanner.getColumn());
}
}
else if (token.type == Scanner.STRING)
{
scanner.get();
attr.decl = DTDDecl.VALUE;
attr.defaultValue = token.value;
}
}
protected DTDNotationList parseNotationList()
throws IOException
{
DTDNotationList notation = new DTDNotationList();
Token token = scanner.get();
if (token.type != Scanner.LPAREN)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in notation: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
for (;;)
{
token = scanner.get();
if (token.type != Scanner.IDENTIFIER)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in notation: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
notation.add(token.value);
token = scanner.peek();
if (token.type == Scanner.RPAREN)
{
scanner.get();
return notation;
}
else if (token.type != Scanner.PIPE)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in notation: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
scanner.get(); // eat the pipe
}
}
protected DTDEnumeration parseEnumeration()
throws IOException
{
DTDEnumeration enumeration = new DTDEnumeration();
for (;;)
{
Token token = scanner.get();
if ((token.type != Scanner.IDENTIFIER) &&
(token.type != Scanner.NMTOKEN))
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in enumeration: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
enumeration.add(token.value);
token = scanner.peek();
if (token.type == Scanner.RPAREN)
{
scanner.get();
return enumeration;
}
else if (token.type != Scanner.PIPE)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid token in enumeration: "+
token.type.name, scanner.getLineNumber(),
scanner.getColumn());
}
scanner.get(); // eat the pipe
}
}
protected void parseEntity()
throws IOException
{
boolean isParsed = false;
Token name = scanner.get();
if (name.type == Scanner.PERCENT)
{
isParsed = true;
name = expect(Scanner.IDENTIFIER);
}
else if (name.type != Scanner.IDENTIFIER)
{
throw new DTDParseException(scanner.getUriId(),
"Invalid entity declaration",
scanner.getLineNumber(), scanner.getColumn());
}
DTDEntity entity = (DTDEntity) dtd.entities.get(name.value);
boolean skip = false;
if (entity == null)
{
entity = new DTDEntity(name.value, defaultLocation);
dtd.entities.put(entity.name, entity);
}
else
{
// 070501 MAW: If the entity already exists, create a dummy entity - this way
// you keep the original definition. Thanks to Jags Krishnamurthy of Object
// Edge for pointing out this problem and for pointing out the solution
entity = new DTDEntity(name.value, defaultLocation);
skip = true;
}
dtd.items.addElement(entity);
entity.isParsed = isParsed;
parseEntityDef(entity);
if (entity.isParsed && (entity.value != null) && !skip)
{
scanner.addEntity(entity.name, entity.value);
}
}
protected void parseEntityDef(DTDEntity entity)
throws IOException
{
Token token = scanner.get();
if (token.type == Scanner.STRING)
{
// Only set the entity value if it hasn't been set yet
// XML 1.0 spec says that you use the first value of
// an entity, not the most recent.
if (entity.value == null)
{
entity.value = token.value;
}
}
else if (token.type == Scanner.IDENTIFIER)
{
if (token.value.equals("SYSTEM"))
{
DTDSystem sys = new DTDSystem();
token = expect(Scanner.STRING);
sys.system = token.value;
entity.externalID = sys;
}
else if (token.value.equals("PUBLIC"))
{
DTDPublic pub = new DTDPublic();
token = expect(Scanner.STRING);
pub.pub = token.value;
token = expect(Scanner.STRING);
pub.system = token.value;
entity.externalID = pub;
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid External ID specification",
scanner.getLineNumber(), scanner.getColumn());
}
// ISSUE: isParsed is set to TRUE if this is a Parameter Entity
// Reference (assuming this is because Parameter Entity
// external references are parsed, whereas General Entity
// external references are irrelevant for this product).
// However, NDATA is only valid if this is
// a General Entity Reference. So, "if" conditional should
// be (!entity.isParsed) rather than (entity.isParsed).
//
//Entity Declaration
// [70] EntityDecl ::= GEDecl | PEDecl
// [71] GEDecl ::= ''
// [72] PEDecl ::= ''
// [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
// [74] PEDef ::= EntityValue | ExternalID
//External Entity Declaration
// [75] ExternalID ::= 'SYSTEM' S SystemLiteral
// | 'PUBLIC' S PubidLiteral S SystemLiteral
// [76] NDataDecl ::= S 'NDATA' S Name [ VC: Notation Declared ]
if (!entity.isParsed) // CHANGE 1
{
token = scanner.peek();
if (token.type == Scanner.IDENTIFIER)
{
if (!token.value.equals("NDATA"))
{
throw new DTDParseException(scanner.getUriId(),
"Invalid NData declaration",
scanner.getLineNumber(), scanner.getColumn());
}
// CHANGE 2: Add call to scanner.get.
// This gets "NDATA" IDENTIFIER.
token = scanner.get();
// Get the NDATA "Name" IDENTIFIER.
token = expect(Scanner.IDENTIFIER);
// Save the ndata value
entity.ndata = token.value;
}
}
}
else
{
throw new DTDParseException(scanner.getUriId(),
"Invalid entity definition",
scanner.getLineNumber(), scanner.getColumn());
}
expect(Scanner.GT);
}
protected void parseNotation()
throws java.io.IOException
{
DTDNotation notation = new DTDNotation();
Token token = expect(Scanner.IDENTIFIER);
notation.name = token.value;
dtd.notations.put(notation.name, notation);
dtd.items.addElement(notation);
token = expect(Scanner.IDENTIFIER);
if (token.value.equals("SYSTEM"))
{
DTDSystem sys = new DTDSystem();
token = expect(Scanner.STRING);
sys.system = token.value;
notation.externalID = sys;
}
else if (token.value.equals("PUBLIC"))
{
DTDPublic pub = new DTDPublic();
token = expect(Scanner.STRING);
pub.pub = token.value;
pub.system = null;
// For , you can have PUBLIC PubidLiteral without
// a SystemLiteral
token = scanner.peek();
if (token.type == Scanner.STRING)
{
token = scanner.get();
pub.system = token.value;
}
notation.externalID = pub;
}
expect(Scanner.GT);
}
public DTDEntity expandEntity(String name)
{
return (DTDEntity) dtd.entities.get(name);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDProcessingInstruction.java 0000644 0001750 0001750 00000002467 07515664513 024521 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents a processing instruction in the DTD
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDProcessingInstruction implements DTDOutput
{
/** The processing instruction text */
public String text;
public DTDProcessingInstruction()
{
}
public DTDProcessingInstruction(String theText)
{
text = theText;
}
public String toString()
{
return text;
}
public void write(PrintWriter out)
throws IOException
{
out.print("");
out.print(text);
out.println("?>");
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDProcessingInstruction)) return false;
DTDProcessingInstruction other = (DTDProcessingInstruction) ob;
if (text == null)
{
if (other.text != null) return false;
}
else
{
if (!text.equals(other.text)) return false;
}
return true;
}
/** Sets the instruction text */
public void setText(String theText)
{
text = theText;
}
/** Retrieves the instruction text */
public String getText()
{
return text;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDPublic.java 0000644 0001750 0001750 00000002433 07515664513 021352 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents an external Public ID in an entity declaration
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDPublic extends DTDExternalID
{
public String pub;
public DTDPublic()
{
}
/** Writes out a public external ID declaration */
public void write(PrintWriter out)
throws IOException
{
out.print("PUBLIC \"");
out.print(pub);
out.print("\"");
if (system != null)
{
out.print(" \"");
out.print(system);
out.print("\"");
}
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDPublic)) return false;
if (!super.equals(ob)) return false;
DTDPublic other = (DTDPublic) ob;
if (pub == null)
{
if (other.pub != null) return false;
}
else
{
if (!pub.equals(other.pub)) return false;
}
return true;
}
/** Sets the public identifier */
public void setPub(String aPub)
{
pub = aPub;
}
/** Retrieves the public identifier */
public String getPub()
{
return pub;
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDSequence.java 0000644 0001750 0001750 00000002037 07515664513 021704 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
/** Represents a sequence in an element's content.
* A sequence is declared in the DTD as (value1,value2,value3,etc.)
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDSequence extends DTDContainer
{
public DTDSequence()
{
}
/** Writes out a declaration for this sequence */
public void write(PrintWriter out)
throws IOException
{
out.print("(");
Enumeration e = getItemsVec().elements();
boolean isFirst = true;
while (e.hasMoreElements())
{
if (!isFirst) out.print(",");
isFirst = false;
DTDItem item = (DTDItem) e.nextElement();
item.write(out);
}
out.print(")");
cardinal.write(out);
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDSequence)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/DTDSystem.java 0000644 0001750 0001750 00000001320 07515664513 021412 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
/** Represents an external System ID in an entity declaration
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
public class DTDSystem extends DTDExternalID
{
public DTDSystem()
{
}
/** Writes out a declaration for this SYSTEM ID */
public void write(PrintWriter out)
{
if (system != null)
{
out.print("SYSTEM \"");
out.print(system);
out.print("\"");
}
}
public boolean equals(Object ob)
{
if (ob == this) return true;
if (!(ob instanceof DTDSystem)) return false;
return super.equals(ob);
}
}
dtdparser-1.21/source/com/wutka/dtd/EntityExpansion.java 0000644 0001750 0001750 00000000155 07515664513 022740 0 ustar arnaud arnaud package com.wutka.dtd;
public interface EntityExpansion
{
public DTDEntity expandEntity(String name);
}
dtdparser-1.21/source/com/wutka/dtd/Scanner.java 0000644 0001750 0001750 00000070622 07521626376 021200 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
/** Lexical scanner for DTD's
*
* @author Mark Wutka
* @version $Revision: 1.19 $ $Date: 2002/07/31 00:19:10 $ by $Author: wutka $
*/
class Scanner
{
public static final TokenType LTQUES = new TokenType(0, "LTQUES");
public static final TokenType IDENTIFIER = new TokenType(1, "IDENTIFIER");
public static final TokenType EQUAL = new TokenType(2, "EQUAL");
public static final TokenType LPAREN = new TokenType(3, "LPAREN");
public static final TokenType RPAREN = new TokenType(4, "RPAREN");
public static final TokenType COMMA = new TokenType(5, "COMMA");
public static final TokenType STRING = new TokenType(6, "STRING");
public static final TokenType QUESGT = new TokenType(7, "QUESGT");
public static final TokenType LTBANG = new TokenType(8, "LTBANG");
public static final TokenType GT = new TokenType(9, "GT");
public static final TokenType PIPE = new TokenType(10, "PIPE");
public static final TokenType QUES = new TokenType(11, "QUES");
public static final TokenType PLUS = new TokenType(12, "PLUS");
public static final TokenType ASTERISK = new TokenType(13, "ASTERISK");
public static final TokenType LT = new TokenType(14, "LT");
public static final TokenType EOF = new TokenType(15, "EOF");
public static final TokenType COMMENT = new TokenType(16, "COMMENT");
public static final TokenType PERCENT = new TokenType(17, "PERCENT");
public static final TokenType CONDITIONAL =
new TokenType(18, "CONDITIONAL");
public static final TokenType ENDCONDITIONAL =
new TokenType(19, "ENDCONDITIONAL");
public static final TokenType NMTOKEN = new TokenType(20, "NMTOKEN");
protected class StreamInfo
{
String id;
Reader in;
int lineNumber = 1;
int column = 1;
StreamInfo(String id, Reader in)
{
this.id = id;
this.in = in;
}
};
protected StreamInfo in;
protected Stack inputStreams;
protected Token nextToken;
protected int nextChar;
protected boolean atEOF;
protected boolean trace;
protected char[] expandBuffer;
protected int expandPos;
protected Hashtable entityExpansion;
protected EntityExpansion expander;
public Scanner(Reader inReader, EntityExpansion anExpander)
{
this(inReader, false, anExpander);
}
public Scanner(Reader inReader, boolean doTrace, EntityExpansion anExpander)
{
in = new StreamInfo("", inReader);
atEOF = false;
trace = doTrace;
expandBuffer = null;
entityExpansion = new Hashtable();
expander = anExpander;
}
public Token peek()
throws IOException
{
if (nextToken == null)
{
nextToken = readNextToken();
}
return nextToken;
}
public Token get()
throws IOException
{
if (nextToken == null)
{
nextToken = readNextToken();
}
Token retval = nextToken;
nextToken = null;
return retval;
}
protected int readNextChar()
throws IOException
{
int ch = in.in.read();
if (ch < 0)
{
if ((inputStreams != null) && (!inputStreams.empty()))
{
in.in.close();
in = (StreamInfo) inputStreams.pop();
return readNextChar();
}
}
return ch;
}
protected int peekChar()
throws IOException
{
if (expandBuffer != null)
{
return (int) expandBuffer[expandPos];
}
if (nextChar == 0)
{
nextChar = readNextChar();
in.column++;
if (nextChar == '\n')
{
in.lineNumber++;
in.column=1;
}
}
return nextChar;
}
protected int read()
throws IOException
{
if (expandBuffer != null)
{
int expNextChar = expandBuffer[expandPos++];
if (expandPos >= expandBuffer.length)
{
expandPos = -1;
expandBuffer = null;
}
if (trace)
{
System.out.print((char) expNextChar);
}
return expNextChar;
}
if (nextChar == 0)
{
peekChar();
}
int retval = nextChar;
nextChar = 0;
if (trace)
{
System.out.print((char) retval);
}
return retval;
}
public String getUntil(char stopChar)
throws IOException
{
StringBuffer out = new StringBuffer();
int ch;
while ((ch = read()) >= 0)
{
if (ch == stopChar)
{
return out.toString();
}
out.append((char) ch);
}
return out.toString();
}
public void skipUntil(char stopChar)
throws IOException
{
int ch;
while ((ch = read()) >= 0)
{
if (ch == stopChar)
{
return;
}
}
return;
}
protected Token readNextToken()
throws IOException
{
for (;;)
{
int ch = read();
if (ch == '<')
{
ch = peekChar();
if (ch == '!')
{
read();
if (peekChar() == '[')
{
read();
return new Token(CONDITIONAL);
}
if (peekChar() != '-')
{
return new Token(LTBANG);
}
else
{
read();
if (peekChar() != '-')
{
throw new DTDParseException(getUriId(),
"Invalid character sequence ')
{
throw new DTDParseException(getUriId(),
"Invalid character sequence --"+
read(), getLineNumber(), getColumn());
}
read();
return new Token(COMMENT, buff.toString());
}
else
{
buff.append('-');
}
}
}
}
}
else if (ch == '?')
{
read();
return new Token(LTQUES);
}
else
{
return new Token(LT);
}
}
else if (ch == '?')
{
// Need to treat ?> as two separate tokens because
// needs the ? as a QUES, not QUESGT
/* ch = peekChar();
if (ch == '>')
{
read();
return new Token(QUESGT);
}
else
{
return new Token(QUES);
}*/
return new Token(QUES);
}
else if ((ch == '"') || (ch == '\''))
{
int quoteChar = ch;
StringBuffer buff = new StringBuffer();
while (peekChar() != quoteChar)
{
ch = read();
if (ch == '\\')
{
buff.append((char) read());
}
else if (ch < 0)
{
break; // IF EOF before getting end quote
}
else
{
buff.append((char) ch);
}
}
read();
return new Token(STRING, buff.toString());
}
else if (ch == '(')
{
return new Token(LPAREN);
}
else if (ch == ')')
{
return new Token(RPAREN);
}
else if (ch == '|')
{
return new Token(PIPE);
}
else if (ch == '>')
{
return new Token(GT);
}
else if (ch == '=')
{
return new Token(EQUAL);
}
else if (ch == '*')
{
return new Token(ASTERISK);
}
else if (ch == ']')
{
if (read() != ']')
{
throw new DTDParseException(getUriId(),
"Illegal character in input stream: "+ch,
getLineNumber(), getColumn());
}
if (read() != '>')
{
throw new DTDParseException(getUriId(),
"Illegal character in input stream: "+ch,
getLineNumber(), getColumn());
}
return new Token(ENDCONDITIONAL);
}
else if (ch == '#')
{
StringBuffer buff = new StringBuffer();
buff.append((char) ch);
if (isIdentifierChar((char) peekChar()))
{
buff.append((char) read());
while (isNameChar((char) peekChar()))
{
buff.append((char) read());
}
}
return new Token(IDENTIFIER, buff.toString());
}
else if ((ch == '&') || (ch == '%'))
{
if ((ch == '%') && Character.isWhitespace((char)peekChar()))
{
return new Token(PERCENT);
}
boolean peRef = (ch == '%');
StringBuffer buff = new StringBuffer();
buff.append((char) ch);
if (isIdentifierChar((char) peekChar()))
{
buff.append((char) read());
while (isNameChar((char) peekChar()))
{
buff.append((char) read());
}
}
if (read() != ';')
{
throw new DTDParseException(getUriId(),
"Expected ';' after reference "+
buff.toString()+", found '"+ch+"'",
getLineNumber(), getColumn());
}
buff.append(';');
if (peRef)
{
if (expandEntity(buff.toString()))
{
continue;
}
else
{
// MAW: Added version 1.17
// If the entity can't be expanded, don't return it, skip it
continue;
}
}
return new Token(IDENTIFIER, buff.toString());
}
else if (ch == '+')
{
return new Token(PLUS);
}
else if (ch == ',')
{
return new Token(COMMA);
}
else if (isIdentifierChar((char) ch))
{
StringBuffer buff = new StringBuffer();
buff.append((char) ch);
while (isNameChar((char) peekChar()))
{
buff.append((char) read());
}
return new Token(IDENTIFIER, buff.toString());
}
else if (isNameChar((char) ch))
{
StringBuffer buff = new StringBuffer();
buff.append((char) ch);
while (isNameChar((char) peekChar()))
{
buff.append((char) read());
}
return new Token(NMTOKEN, buff.toString());
}
else if (ch < 0)
{
if (atEOF)
{
throw new IOException("Read past EOF");
}
atEOF = true;
return new Token(EOF);
}
else if (Character.isWhitespace((char) ch))
{
continue;
}
else
{
throw new DTDParseException(getUriId(),
"Illegal character in input stream: "+ch,
getLineNumber(), getColumn());
}
}
}
public void skipConditional()
throws IOException
{
// 070401 MAW: Fix for nested conditionals provided by Noah Fike
// BEGIN CHANGE
int ch = 0;
int nestingDepth = 0; // Add nestingDepth parameter
// Everything is ignored within an ignored section, except the
// sub-section delimiters ''. These must be balanced,
// but no section keyword is required:
// Conditional Section
//[61] conditionalSect ::= includeSect | ignoreSect
//[62] includeSect ::= ''
//[63] ignoreSect ::= ''
//[64] ignoreSectContents ::= Ignore ('' Ignore)*
//[65] Ignore ::= Char* - (Char* ('') Char*)
for (;;)
{
if ( ch != ']' )
{
ch = read();
}
if (ch == ']')
{
ch = read();
if (ch == ']')
{
ch = read();
if (ch == '>')
{
if ( nestingDepth == 0)
{
// The end of the IGNORE conditional section
// has been found. Break out of for loop.
break;
}
else
{
// We are within an ignoreSectContents section. Decrement
// the nesting depth to represent that this section has
// been ended.
nestingDepth--;
}
}
}
}
// See if this is the first character of the beginning of a new section.
if (ch == '<')
{
ch = read();
if ( ch == '!' )
{
ch = read();
if ( ch == '[' )
{
// The beginning of a new ignoreSectContents section
// has been found. Increment nesting depth.
nestingDepth++;
}
}
}
}
// END CHANGE
}
public String getUriId() { return(in.id); }
public int getLineNumber() { return in.lineNumber; }
public int getColumn() { return in.column; }
public boolean isIdentifierChar(char ch)
{
if (isLetter(ch) ||
(ch == '_') || (ch == ':'))
{
return true;
}
return false;
}
public boolean isNameChar(char ch)
{
if (isLetter(ch) || isDigit(ch) ||
(ch == '-') || (ch == '_') || (ch == '.') || (ch == ':')
|| isCombiningChar(ch) || isExtender(ch))
{
return true;
}
return false;
}
public boolean isLetter(char ch)
{
return isBaseChar(ch) || isIdeographic(ch);
}
public boolean isBaseChar(char ch)
{
for (int i=0; i < letterRanges.length; i++)
{
if (ch < letterRanges[i][0]) return false;
if ((ch >= letterRanges[i][0]) &&
(ch <= letterRanges[i][1])) return true;
}
return false;
}
public boolean isIdeographic(char ch)
{
if (ch < 0x4e00) return false;
if ((ch >= 0x4e00) && (ch <= 0x9fa5)) return true;
if (ch == 0x3007) return true;
if ((ch >= 0x3021) && (ch <= 0x3029)) return true;
return false;
}
public boolean isDigit(char ch)
{
if ((ch >= 0x0030) && (ch <= 0x0039)) return true;
if (ch < 0x0660) return false;
if ((ch >= 0x0660) && (ch <= 0x0669)) return true;
if (ch < 0x06f0) return false;
if ((ch >= 0x06f0) && (ch <= 0x06f9)) return true;
if (ch < 0x0966) return false;
if ((ch >= 0x0966) && (ch <= 0x096f)) return true;
if (ch < 0x09e6) return false;
if ((ch >= 0x09e6) && (ch <= 0x09ef)) return true;
if (ch < 0x0a66) return false;
if ((ch >= 0x0a66) && (ch <= 0x0a6f)) return true;
if (ch < 0x0ae6) return false;
if ((ch >= 0x0ae6) && (ch <= 0x0aef)) return true;
if (ch < 0x0b66) return false;
if ((ch >= 0x0b66) && (ch <= 0x0b6f)) return true;
if (ch < 0x0be7) return false;
if ((ch >= 0x0be7) && (ch <= 0x0bef)) return true;
if (ch < 0x0c66) return false;
if ((ch >= 0x0c66) && (ch <= 0x0c6f)) return true;
if (ch < 0x0ce6) return false;
if ((ch >= 0x0ce6) && (ch <= 0x0cef)) return true;
if (ch < 0x0d66) return false;
if ((ch >= 0x0d66) && (ch <= 0x0d6f)) return true;
if (ch < 0x0e50) return false;
if ((ch >= 0x0e50) && (ch <= 0x0e59)) return true;
if (ch < 0x0ed0) return false;
if ((ch >= 0x0ed0) && (ch <= 0x0ed9)) return true;
if (ch < 0x0f20) return false;
if ((ch >= 0x0f20) && (ch <= 0x0f29)) return true;
return false;
}
public boolean isCombiningChar(char ch)
{
if (ch < 0x0300) return false;
if ((ch >= 0x0300) && (ch <= 0x0345)) return true;
if ((ch >= 0x0360) && (ch <= 0x0361)) return true;
if ((ch >= 0x0483) && (ch <= 0x0486)) return true;
if ((ch >= 0x0591) && (ch <= 0x05a1)) return true;
if ((ch >= 0x05a3) && (ch <= 0x05b9)) return true;
if ((ch >= 0x05bb) && (ch <= 0x05bd)) return true;
if (ch == 0x05bf) return true;
if ((ch >= 0x05c1) && (ch <= 0x05c2)) return true;
if (ch == 0x05c4) return true;
if ((ch >= 0x064b) && (ch <= 0x0652)) return true;
if (ch == 0x0670) return true;
if ((ch >= 0x06d6) && (ch <= 0x06dc)) return true;
if ((ch >= 0x06dd) && (ch <= 0x06df)) return true;
if ((ch >= 0x06e0) && (ch <= 0x06e4)) return true;
if ((ch >= 0x06e7) && (ch <= 0x06e8)) return true;
if ((ch >= 0x06ea) && (ch <= 0x06ed)) return true;
if ((ch >= 0x0901) && (ch <= 0x0903)) return true;
if (ch == 0x093c) return true;
if ((ch >= 0x093e) && (ch <= 0x094c)) return true;
if (ch == 0x094d) return true;
if ((ch >= 0x0951) && (ch <= 0x0954)) return true;
if ((ch >= 0x0962) && (ch <= 0x0963)) return true;
if ((ch >= 0x0981) && (ch <= 0x0983)) return true;
if (ch == 0x09bc) return true;
if (ch == 0x09be) return true;
if (ch == 0x09bf) return true;
if ((ch >= 0x09c0) && (ch <= 0x09c4)) return true;
if ((ch >= 0x09c7) && (ch <= 0x09c8)) return true;
if ((ch >= 0x09cb) && (ch <= 0x09cd)) return true;
if (ch == 0x09d7) return true;
if ((ch >= 0x09e2) && (ch <= 0x09e3)) return true;
if (ch == 0x0a02) return true;
if (ch == 0x0a3c) return true;
if (ch == 0x0a3e) return true;
if (ch == 0x0a3f) return true;
if ((ch >= 0x0a40) && (ch <= 0x0a42)) return true;
if ((ch >= 0x0a47) && (ch <= 0x0a48)) return true;
if ((ch >= 0x0a4b) && (ch <= 0x0a4d)) return true;
if ((ch >= 0x0a70) && (ch <= 0x0a71)) return true;
if ((ch >= 0x0a81) && (ch <= 0x0a83)) return true;
if (ch == 0x0abc) return true;
if ((ch >= 0x0abe) && (ch <= 0x0ac5)) return true;
if ((ch >= 0x0ac7) && (ch <= 0x0ac9)) return true;
if ((ch >= 0x0acb) && (ch <= 0x0acd)) return true;
if ((ch >= 0x0b01) && (ch <= 0x0b03)) return true;
if (ch == 0x0b3c) return true;
if ((ch >= 0x0b3e) && (ch <= 0x0b43)) return true;
if ((ch >= 0x0b47) && (ch <= 0x0b48)) return true;
if ((ch >= 0x0b4b) && (ch <= 0x0b4d)) return true;
if ((ch >= 0x0b56) && (ch <= 0x0b57)) return true;
if ((ch >= 0x0b82) && (ch <= 0x0b83)) return true;
if ((ch >= 0x0bbe) && (ch <= 0x0bc2)) return true;
if ((ch >= 0x0bc6) && (ch <= 0x0bc8)) return true;
if ((ch >= 0x0bca) && (ch <= 0x0bcd)) return true;
if (ch == 0x0bd7) return true;
if ((ch >= 0x0c01) && (ch <= 0x0c03)) return true;
if ((ch >= 0x0c3e) && (ch <= 0x0c44)) return true;
if ((ch >= 0x0c46) && (ch <= 0x0c48)) return true;
if ((ch >= 0x0c4a) && (ch <= 0x0c4d)) return true;
if ((ch >= 0x0c55) && (ch <= 0x0c56)) return true;
if ((ch >= 0x0c82) && (ch <= 0x0c83)) return true;
if ((ch >= 0x0cbe) && (ch <= 0x0cc4)) return true;
if ((ch >= 0x0cc6) && (ch <= 0x0cc8)) return true;
if ((ch >= 0x0cca) && (ch <= 0x0ccd)) return true;
if ((ch >= 0x0cd5) && (ch <= 0x0cd6)) return true;
if ((ch >= 0x0d02) && (ch <= 0x0d03)) return true;
if ((ch >= 0x0d3e) && (ch <= 0x0d43)) return true;
if ((ch >= 0x0d46) && (ch <= 0x0d48)) return true;
if ((ch >= 0x0d4a) && (ch <= 0x0d4d)) return true;
if (ch == 0x0d57) return true;
if (ch == 0x0e31) return true;
if ((ch >= 0x0e34) && (ch <= 0x0e3a)) return true;
if ((ch >= 0x0e47) && (ch <= 0x0e4e)) return true;
if (ch == 0x0eb1) return true;
if ((ch >= 0x0eb4) && (ch <= 0x0eb9)) return true;
if ((ch >= 0x0ebb) && (ch <= 0x0ebc)) return true;
if ((ch >= 0x0ec8) && (ch <= 0x0ecd)) return true;
if ((ch >= 0x0f18) && (ch <= 0x0f19)) return true;
if (ch == 0x0f35) return true;
if (ch == 0x0f37) return true;
if (ch == 0x0f39) return true;
if (ch == 0x0f3e) return true;
if (ch == 0x0f3f) return true;
if ((ch >= 0x0f71) && (ch <= 0x0f84)) return true;
if ((ch >= 0x0f86) && (ch <= 0x0f8b)) return true;
if ((ch >= 0x0f90) && (ch <= 0x0f95)) return true;
if (ch == 0x0f97) return true;
if ((ch >= 0x0f99) && (ch <= 0x0fad)) return true;
if ((ch >= 0x0fb1) && (ch <= 0x0fb7)) return true;
if (ch == 0x0fb9) return true;
if ((ch >= 0x20d0) && (ch <= 0x20dc)) return true;
if (ch == 0x20e1) return true;
if ((ch >= 0x302a) && (ch <= 0x302f)) return true;
if (ch == 0x3099) return true;
if (ch == 0x309a) return true;
return false;
}
public boolean isExtender(char ch)
{
if (ch < 0x00b7) return false;
if ((ch == 0x00b7) || (ch == 0x02d0) || (ch == 0x02d1) ||
(ch == 0x0387) || (ch == 0x0640) || (ch == 0x0e46) ||
((ch >= 0x3031) && (ch <= 0x3035)) ||
((ch >= 0x309d) && (ch <= 0x309e)) ||
((ch >= 0x30fc) && (ch <= 0x30fe))) return true;
return false;
}
public boolean expandEntity(String entityName)
throws IOException
{
String entity = (String) entityExpansion.get(entityName);
if (entity != null)
{
expand(entity.toCharArray());
return true;
}
entityName = entityName.substring(1, entityName.length()-1);
//System.out.println("Trying to expand: "+entityName);
DTDEntity realEntity = expander.expandEntity(entityName);
if (realEntity != null)
{
//System.out.println("Expanded: "+entityName);
Reader entityIn = realEntity.getReader();
if (entityIn != null)
{
if (inputStreams == null)
{
inputStreams = new Stack();
}
inputStreams.push(in);
in = new StreamInfo(realEntity.getExternalId(), entityIn);
return true;
}
}
return false;
}
public void expand(char[] expandChars)
{
if (expandBuffer != null)
{
int oldCharsLeft = expandBuffer.length - expandPos;
char[] newExp = new char[oldCharsLeft + expandChars.length];
System.arraycopy(expandChars, 0, newExp, 0,
expandChars.length);
System.arraycopy(expandBuffer, expandPos, newExp,
expandChars.length, oldCharsLeft);
expandPos = 0;
expandBuffer = newExp;
if (expandBuffer.length == 0)
{
expandBuffer = null;
expandPos = -1;
}
}
else
{
expandBuffer = expandChars;
expandPos = 0;
if (expandBuffer.length == 0)
{
expandBuffer = null;
expandPos = -1;
}
}
}
public void addEntity(String entityName, String entityValue)
{
entityExpansion.put("%"+entityName+";", entityValue);
}
public static char letterRanges[][] = {
{ 0x0041, 0x005A }, { 0x0061, 0x007A }, { 0x00C0, 0x00D6 },
{ 0x00D8, 0x00F6 }, { 0x00F8, 0x00FF }, { 0x0100, 0x0131 },
{ 0x0134, 0x013E }, { 0x0141, 0x0148 }, { 0x014A, 0x017E },
{ 0x0180, 0x01C3 }, { 0x01CD, 0x01F0 }, { 0x01F4, 0x01F5 },
{ 0x01FA, 0x0217 }, { 0x0250, 0x02A8 }, { 0x02BB, 0x02C1 },
{ 0x0386, 0x0386 }, { 0x0388, 0x038A }, { 0x038C, 0x038C },
{ 0x038E, 0x03A1 }, { 0x03A3, 0x03CE }, { 0x03D0, 0x03D6 },
{ 0x03DA, 0x03DA }, { 0x03DC, 0x03DC }, { 0x03DE, 0x03DE },
{ 0x03E0, 0x03E0 }, { 0x03E2, 0x03F3 }, { 0x0401, 0x040C },
{ 0x040E, 0x044F }, { 0x0451, 0x045C }, { 0x045E, 0x0481 },
{ 0x0490, 0x04C4 }, { 0x04C7, 0x04C8 }, { 0x04CB, 0x04CC },
{ 0x04D0, 0x04EB }, { 0x04EE, 0x04F5 }, { 0x04F8, 0x04F9 },
{ 0x0531, 0x0556 }, { 0x0559, 0x0559 }, { 0x0561, 0x0586 },
{ 0x05D0, 0x05EA }, { 0x05F0, 0x05F2 }, { 0x0621, 0x063A },
{ 0x0641, 0x064A }, { 0x0671, 0x06B7 }, { 0x06BA, 0x06BE },
{ 0x06C0, 0x06CE }, { 0x06D0, 0x06D3 }, { 0x06D5, 0x06D5 },
{ 0x06E5, 0x06E6 }, { 0x0905, 0x0939 }, { 0x093D, 0x093D },
{ 0x0958, 0x0961 }, { 0x0985, 0x098C }, { 0x098F, 0x0990 },
{ 0x0993, 0x09A8 }, { 0x09AA, 0x09B0 }, { 0x09B2, 0x09B2 },
{ 0x09B6, 0x09B9 }, { 0x09DC, 0x09DD }, { 0x09DF, 0x09E1 },
{ 0x09F0, 0x09F1 }, { 0x0A05, 0x0A0A }, { 0x0A0F, 0x0A10 },
{ 0x0A13, 0x0A28 }, { 0x0A2A, 0x0A30 }, { 0x0A32, 0x0A33 },
{ 0x0A35, 0x0A36 }, { 0x0A38, 0x0A39 }, { 0x0A59, 0x0A5C },
{ 0x0A5E, 0x0A5E }, { 0x0A72, 0x0A74 }, { 0x0A85, 0x0A8B },
{ 0x0A8D, 0x0A8D }, { 0x0A8F, 0x0A91 }, { 0x0A93, 0x0AA8 },
{ 0x0AAA, 0x0AB0 }, { 0x0AB2, 0x0AB3 }, { 0x0AB5, 0x0AB9 },
{ 0x0ABD, 0x0ABD }, { 0x0AE0, 0x0AE0 }, { 0x0B05, 0x0B0C },
{ 0x0B0F, 0x0B10 }, { 0x0B13, 0x0B28 }, { 0x0B2A, 0x0B30 },
{ 0x0B32, 0x0B33 }, { 0x0B36, 0x0B39 }, { 0x0B3D, 0x0B3D },
{ 0x0B5C, 0x0B5D }, { 0x0B5F, 0x0B61 }, { 0x0B85, 0x0B8A },
{ 0x0B8E, 0x0B90 }, { 0x0B92, 0x0B95 }, { 0x0B99, 0x0B9A },
{ 0x0B9C, 0x0B9C }, { 0x0B9E, 0x0B9F }, { 0x0BA3, 0x0BA4 },
{ 0x0BA8, 0x0BAA }, { 0x0BAE, 0x0BB5 }, { 0x0BB7, 0x0BB9 },
{ 0x0C05, 0x0C0C }, { 0x0C0E, 0x0C10 }, { 0x0C12, 0x0C28 },
{ 0x0C2A, 0x0C33 }, { 0x0C35, 0x0C39 }, { 0x0C60, 0x0C61 },
{ 0x0C85, 0x0C8C }, { 0x0C8E, 0x0C90 }, { 0x0C92, 0x0CA8 },
{ 0x0CAA, 0x0CB3 }, { 0x0CB5, 0x0CB9 }, { 0x0CDE, 0x0CDE },
{ 0x0CE0, 0x0CE1 }, { 0x0D05, 0x0D0C }, { 0x0D0E, 0x0D10 },
{ 0x0D12, 0x0D28 }, { 0x0D2A, 0x0D39 }, { 0x0D60, 0x0D61 },
{ 0x0E01, 0x0E2E }, { 0x0E30, 0x0E30 }, { 0x0E32, 0x0E33 },
{ 0x0E40, 0x0E45 }, { 0x0E81, 0x0E82 }, { 0x0E84, 0x0E84 },
{ 0x0E87, 0x0E88 }, { 0x0E8A, 0x0E8A }, { 0x0E8D, 0x0E8D },
{ 0x0E94, 0x0E97 }, { 0x0E99, 0x0E9F }, { 0x0EA1, 0x0EA3 },
{ 0x0EA5, 0x0EA5 }, { 0x0EA7, 0x0EA7 }, { 0x0EAA, 0x0EAB },
{ 0x0EAD, 0x0EAE }, { 0x0EB0, 0x0EB0 }, { 0x0EB2, 0x0EB3 },
{ 0x0EBD, 0x0EBD }, { 0x0EC0, 0x0EC4 }, { 0x0F40, 0x0F47 },
{ 0x0F49, 0x0F69 }, { 0x10A0, 0x10C5 }, { 0x10D0, 0x10F6 },
{ 0x1100, 0x1100 }, { 0x1102, 0x1103 }, { 0x1105, 0x1107 },
{ 0x1109, 0x1109 }, { 0x110B, 0x110C }, { 0x110E, 0x1112 },
{ 0x113C, 0x113C }, { 0x113E, 0x113E }, { 0x1140, 0x1140 },
{ 0x114C, 0x114C }, { 0x114E, 0x114E }, { 0x1150, 0x1150 },
{ 0x1154, 0x1155 }, { 0x1159, 0x1159 }, { 0x115F, 0x1161 },
{ 0x1163, 0x1163 }, { 0x1165, 0x1165 }, { 0x1167, 0x1167 },
{ 0x1169, 0x1169 }, { 0x116D, 0x116E }, { 0x1172, 0x1173 },
{ 0x1175, 0x1175 }, { 0x119E, 0x119E }, { 0x11A8, 0x11A8 },
{ 0x11AB, 0x11AB }, { 0x11AE, 0x11AF }, { 0x11B7, 0x11B8 },
{ 0x11BA, 0x11BA }, { 0x11BC, 0x11C2 }, { 0x11EB, 0x11EB },
{ 0x11F0, 0x11F0 }, { 0x11F9, 0x11F9 }, { 0x1E00, 0x1E9B },
{ 0x1EA0, 0x1EF9 }, { 0x1F00, 0x1F15 }, { 0x1F18, 0x1F1D },
{ 0x1F20, 0x1F45 }, { 0x1F48, 0x1F4D }, { 0x1F50, 0x1F57 },
{ 0x1F59, 0x1F59 }, { 0x1F5B, 0x1F5B }, { 0x1F5D, 0x1F5D },
{ 0x1F5F, 0x1F7D }, { 0x1F80, 0x1FB4 }, { 0x1FB6, 0x1FBC },
{ 0x1FBE, 0x1FBE }, { 0x1FC2, 0x1FC4 }, { 0x1FC6, 0x1FCC },
{ 0x1FD0, 0x1FD3 }, { 0x1FD6, 0x1FDB }, { 0x1FE0, 0x1FEC },
{ 0x1FF2, 0x1FF4 }, { 0x1FF6, 0x1FFC }, { 0x2126, 0x2126 },
{ 0x212A, 0x212B }, { 0x212E, 0x212E }, { 0x2180, 0x2182 },
{ 0x3041, 0x3094 }, { 0x30A1, 0x30FA }, { 0x3105, 0x312C },
{ 0xAC00, 0xD7A3 }
};
}
dtdparser-1.21/source/com/wutka/dtd/Token.java 0000644 0001750 0001750 00000000641 07515664513 020657 0 ustar arnaud arnaud package com.wutka.dtd;
/** Token returned by the lexical scanner
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
class Token
{
public TokenType type;
public String value;
public Token(TokenType aType)
{
type = aType;
value = null;
}
public Token(TokenType aType, String aValue)
{
type = aType;
value = aValue;
}
}
dtdparser-1.21/source/com/wutka/dtd/TokenType.java 0000644 0001750 0001750 00000001166 07515664513 021524 0 ustar arnaud arnaud package com.wutka.dtd;
/** Enumerated value representing the type of a token
*
* @author Mark Wutka
* @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
*/
class TokenType
{
public int value;
public String name;
public TokenType(int aValue, String aName)
{
value = aValue;
name = aName;
}
public boolean equals(Object o)
{
if (this == o) return true;
if (!(o instanceof TokenType)) return false;
TokenType other = (TokenType) o;
if (other.value == value) return true;
return false;
}
public int hashCode()
{
return name.hashCode();
}
}
dtdparser-1.21/source/com/wutka/dtd/Tokenize.java 0000644 0001750 0001750 00000016747 07520771230 021374 0 ustar arnaud arnaud package com.wutka.dtd;
import java.io.*;
import java.util.*;
import java.net.URL;
/** Example program to read a DTD and print out its object model
*
* @author Mark Wutka
* @version $Revision: 1.17 $ $Date: 2002/07/28 13:33:12 $ by $Author: wutka $
*/
class Tokenize
{
public static void main(String[] args)
{
try
{
DTDParser parser = null;
// MAW Version 1.17
// If it looks like the filename may be a URL, use the URL class
if (args[0].indexOf("://") > 0)
{
parser = new DTDParser(new URL(args[0]), true);
}
else
{
parser = new DTDParser(new File(args[0]), true);
}
// Parse the DTD and ask the parser to guess the root element
DTD dtd = parser.parse(true);
if (dtd.rootElement != null)
{
System.out.println("Root element is probably: "+
dtd.rootElement.name);
}
Enumeration e = dtd.elements.elements();
while (e.hasMoreElements())
{
DTDElement elem = (DTDElement) e.nextElement();
System.out.println("Element: "+elem.name);
System.out.print(" Content: ");
dumpDTDItem(elem.content);
System.out.println();
if (elem.attributes.size() > 0)
{
System.out.println(" Attributes: ");
Enumeration attrs = elem.attributes.elements();
while (attrs.hasMoreElements())
{
System.out.print(" ");
DTDAttribute attr = (DTDAttribute) attrs.nextElement();
dumpAttribute(attr);
}
System.out.println();
}
}
e = dtd.entities.elements();
while (e.hasMoreElements())
{
DTDEntity entity = (DTDEntity) e.nextElement();
if (entity.isParsed) System.out.print("Parsed ");
System.out.println("Entity: "+entity.name);
if (entity.value != null)
{
System.out.println(" Value: "+entity.value);
}
if (entity.externalID != null)
{
if (entity.externalID instanceof DTDSystem)
{
System.out.println(" System: "+
entity.externalID.system);
}
else
{
DTDPublic pub = (DTDPublic) entity.externalID;
System.out.println(" Public: "+
pub.pub+" "+pub.system);
}
}
if (entity.ndata != null)
{
System.out.println(" NDATA "+entity.ndata);
}
}
e = dtd.notations.elements();
while (e.hasMoreElements())
{
DTDNotation notation = (DTDNotation) e.nextElement();
System.out.println("Notation: "+notation.name);
if (notation.externalID != null)
{
if (notation.externalID instanceof DTDSystem)
{
System.out.println(" System: "+
notation.externalID.system);
}
else
{
DTDPublic pub = (DTDPublic) notation.externalID;
System.out.print(" Public: "+
pub.pub+" ");
if (pub.system != null)
{
System.out.println(pub.system);
}
else
{
System.out.println();
}
}
}
}
}
catch (Exception exc)
{
exc.printStackTrace(System.out);
}
}
public static void dumpDTDItem(DTDItem item)
{
if (item == null) return;
if (item instanceof DTDAny)
{
System.out.print("Any");
}
else if (item instanceof DTDEmpty)
{
System.out.print("Empty");
}
else if (item instanceof DTDName)
{
System.out.print(((DTDName) item).value);
}
else if (item instanceof DTDChoice)
{
System.out.print("(");
DTDItem[] items = ((DTDChoice) item).getItems();
for (int i=0; i < items.length; i++)
{
if (i > 0) System.out.print("|");
dumpDTDItem(items[i]);
}
System.out.print(")");
}
else if (item instanceof DTDSequence)
{
System.out.print("(");
DTDItem[] items = ((DTDSequence) item).getItems();
for (int i=0; i < items.length; i++)
{
if (i > 0) System.out.print(",");
dumpDTDItem(items[i]);
}
System.out.print(")");
}
else if (item instanceof DTDMixed)
{
System.out.print("(");
DTDItem[] items = ((DTDMixed) item).getItems();
for (int i=0; i < items.length; i++)
{
if (i > 0) System.out.print(",");
dumpDTDItem(items[i]);
}
System.out.print(")");
}
else if (item instanceof DTDPCData)
{
System.out.print("#PCDATA");
}
if (item.cardinal == DTDCardinal.OPTIONAL)
{
System.out.print("?");
}
else if (item.cardinal == DTDCardinal.ZEROMANY)
{
System.out.print("*");
}
else if (item.cardinal == DTDCardinal.ONEMANY)
{
System.out.print("+");
}
}
public static void dumpAttribute(DTDAttribute attr)
{
System.out.print(attr.name+" ");
if (attr.type instanceof String)
{
System.out.print(attr.type);
}
else if (attr.type instanceof DTDEnumeration)
{
System.out.print("(");
String[] items = ((DTDEnumeration) attr.type).getItems();
for (int i=0; i < items.length; i++)
{
if (i > 0) System.out.print(",");
System.out.print(items[i]);
}
System.out.print(")");
}
else if (attr.type instanceof DTDNotationList)
{
System.out.print("Notation (");
String[] items = ((DTDNotationList) attr.type).getItems();
for (int i=0; i < items.length; i++)
{
if (i > 0) System.out.print(",");
System.out.print(items[i]);
}
System.out.print(")");
}
if (attr.decl != null)
{
System.out.print(" "+attr.decl.name);
}
if (attr.defaultValue != null)
{
System.out.print(" "+attr.defaultValue);
}
System.out.println();
}
}
dtdparser-1.21/ASL_LICENSE 0000644 0001750 0001750 00000003506 07642407107 014452 0 ustar arnaud arnaud Apache Software License
Version 1.1
Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment:
"This product includes software developed by Mark Wutka (http://www.wutka.com/)."
Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear.
4. The names "Wutka" and "Mark Wutka" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact mark@wutka.com.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dtdparser-1.21/CHANGES 0000644 0001750 0001750 00000000764 07521627212 013741 0 ustar arnaud arnaud Version 1.19
============
Changed expansion of entities to take the first definition of the entity
instead of the most recent (required by XML specification)
Modified scanner to parse identifiers and nmtokens correctly - allowed
identifiers to begin with : or _.
Fixed parsing of #PCDATA to conform to XML specification. If #PCDATA appears
by itself (i.e. (#PCDATA) ), don't allow * after it. If #PCDATA appears at
the beginning of a list (i.e. (#PCDATA|foo|bar|baz) ), require '*' to
follow it.
dtdparser-1.21/LICENSE 0000644 0001750 0001750 00000063476 07515664511 013772 0 ustar arnaud arnaud GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
dtdparser-1.21/LICENSE.INFO 0000644 0001750 0001750 00000000636 07642407152 014506 0 ustar arnaud arnaud This software is now available under two different licenses. You can use it
under the terms of the LGPL license (see the LICENSE file) or the Apache-style
license (the ASL_LICENSE) file.
If you use the software under one license, you are not obligated to fulfill any
of the requirements of the other license (i.e. if you use the Apache-style
license, you don't have to comply with the LGPL terms or vice-versa).
dtdparser-1.21/README 0000644 0001750 0001750 00000001272 07515664511 013627 0 ustar arnaud arnaud This is a rewrite of the DTD parser from the JOX library. It should parse
most DTD's fine. It only understands comments, ,
although comments and ?> items are ignored.
If there are other items that belong in a DTD, I'll try to include them
in here.
To use the parser, just create a DTDParser object with a Reader that is
reading the DTD (i.e. if you need to read a DTD from a URL, you need to
create the URLConnection yourself and slap a Reader around it).
The Tokenize.java program reads a DTD and spits out a lot of the
information returned if you need to see how to navigate through the
DTD object.
dtdparser-1.21/build.xml 0000644 0001750 0001750 00000006220 07521227733 014564 0 ustar arnaud arnaud
dtdparser-1.21/product.properties 0000644 0001750 0001750 00000000325 07546314713 016543 0 ustar arnaud arnaud # These are the product properties. This file should only be modified
# when a new release is being made.
# product name
prod.name=dtdparser
# product version
prod.version.major=1
prod.version.minor=20
# EOF