X4O: Formatted the SAX3 package to eclipse-160 (code+comment)
This commit is contained in:
parent
2819b36a45
commit
a61ce241e1
26 changed files with 1192 additions and 909 deletions
|
|
@ -127,7 +127,9 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
text = "JavaScript is disabled on your browser.";
|
||||
}
|
||||
printTagStart(Tag.noscript);
|
||||
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
|
||||
printTagStart(Tag.div);
|
||||
printCharacters(text);
|
||||
printTagEnd(Tag.div);
|
||||
printTagEnd(Tag.noscript);
|
||||
}
|
||||
|
||||
|
|
@ -244,37 +246,138 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
public enum Tag {
|
||||
|
||||
/* Deprecated TAGS */
|
||||
frameset,frame,noframes,tt,font,dir,center,strike,
|
||||
big,basefont,acronym,applet,iframe,
|
||||
frameset,
|
||||
frame,
|
||||
noframes,
|
||||
tt,
|
||||
font,
|
||||
dir,
|
||||
center,
|
||||
strike,
|
||||
big,
|
||||
basefont,
|
||||
acronym,
|
||||
applet,
|
||||
iframe,
|
||||
|
||||
/* HTML 4 TAGS */
|
||||
html,head,title,meta,link,base,body,script,style,
|
||||
html,
|
||||
head,
|
||||
title,
|
||||
meta,
|
||||
link,
|
||||
base,
|
||||
body,
|
||||
script,
|
||||
style,
|
||||
|
||||
h1,h2,h3,h4,h5,h6,
|
||||
a,div,span,p,pre,img,hr,br,
|
||||
b,em,strong,small,noscript,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
a,
|
||||
div,
|
||||
span,
|
||||
p,
|
||||
pre,
|
||||
img,
|
||||
hr,
|
||||
br,
|
||||
b,
|
||||
em,
|
||||
strong,
|
||||
small,
|
||||
noscript,
|
||||
|
||||
ul,li,dl,dt,dd,ol,
|
||||
table,thead,tfoot,tbody,caption,th,tr,td,
|
||||
ul,
|
||||
li,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ol,
|
||||
table,
|
||||
thead,
|
||||
tfoot,
|
||||
tbody,
|
||||
caption,
|
||||
th,
|
||||
tr,
|
||||
td,
|
||||
|
||||
abbr,address,area,bdo,blockquote,
|
||||
cite,code,col,colgroup,del,dfn,i,ins,
|
||||
kbd,legend,map,menu,object,param,
|
||||
optgroup,q,s,samp,sub,u,var,
|
||||
abbr,
|
||||
address,
|
||||
area,
|
||||
bdo,
|
||||
blockquote,
|
||||
cite,
|
||||
code,
|
||||
col,
|
||||
colgroup,
|
||||
del,
|
||||
dfn,
|
||||
i,
|
||||
ins,
|
||||
kbd,
|
||||
legend,
|
||||
map,
|
||||
menu,
|
||||
object,
|
||||
param,
|
||||
optgroup,
|
||||
q,
|
||||
s,
|
||||
samp,
|
||||
sub,
|
||||
u,
|
||||
var,
|
||||
|
||||
form,fieldset,input,option,
|
||||
label,button,select,textarea,
|
||||
form,
|
||||
fieldset,
|
||||
input,
|
||||
option,
|
||||
label,
|
||||
button,
|
||||
select,
|
||||
textarea,
|
||||
|
||||
/* HTML 5 TAGS */
|
||||
canvas,audio,video,source,embed,track,
|
||||
datalist,keygen,output,
|
||||
article,aside,bdi,command,details,dialog,summary,
|
||||
figure,figcaption,footer,header,hgroup,mark,meter,
|
||||
nav,progress,ruby,rt,rp,section,time,wbr,
|
||||
;
|
||||
canvas,
|
||||
audio,
|
||||
video,
|
||||
source,
|
||||
embed,
|
||||
track,
|
||||
datalist,
|
||||
keygen,
|
||||
output,
|
||||
article,
|
||||
aside,
|
||||
bdi,
|
||||
command,
|
||||
details,
|
||||
dialog,
|
||||
summary,
|
||||
figure,
|
||||
figcaption,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
mark,
|
||||
meter,
|
||||
nav,
|
||||
progress,
|
||||
ruby,
|
||||
rt,
|
||||
rp,
|
||||
section,
|
||||
time,
|
||||
wbr,;
|
||||
}
|
||||
|
||||
private final static String DOCTYPE_NAME = "HTML PUBLIC";
|
||||
|
||||
public enum DocType {
|
||||
/* Order from worst to better. */
|
||||
HTML_5("html", "", ""),
|
||||
|
|
@ -287,8 +390,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
XHTML_1_TRANSITIONAL(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.0 Transitional//EN\"", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
|
||||
XHTML_1_STRICT(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.0 Strict//EN\"", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
|
||||
|
||||
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
|
||||
;
|
||||
XHTML_11(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.1//EN\"", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),;
|
||||
|
||||
private final String name;
|
||||
private final String publicId;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public SAX3WriterXml(Writer out, String encoding) {
|
||||
|
|
@ -49,6 +50,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public SAX3WriterXml(Writer out) {
|
||||
|
|
@ -57,6 +59,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||
*/
|
||||
|
|
@ -66,6 +69,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
* @param encoding The OutputStream encoding.
|
||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||
|
|
|
|||
|
|
@ -75,10 +75,35 @@ public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag,SAX3WriterXm
|
|||
}
|
||||
|
||||
public enum Tag {
|
||||
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
|
||||
choice,complexContent,complexType,documentation,element,extension,
|
||||
field,group,_import,include,key,keyref,list,notation,
|
||||
redefine,restriction,schema,selector,sequence,
|
||||
simpleContent,simpleType,unoin,unique
|
||||
all,
|
||||
annotation,
|
||||
any,
|
||||
anyAttribute,
|
||||
appinfo,
|
||||
attribute,
|
||||
attributeGroup,
|
||||
choice,
|
||||
complexContent,
|
||||
complexType,
|
||||
documentation,
|
||||
element,
|
||||
extension,
|
||||
field,
|
||||
group,
|
||||
_import,
|
||||
include,
|
||||
key,
|
||||
keyref,
|
||||
list,
|
||||
notation,
|
||||
redefine,
|
||||
restriction,
|
||||
schema,
|
||||
selector,
|
||||
sequence,
|
||||
simpleContent,
|
||||
simpleType,
|
||||
unoin,
|
||||
unique
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public abstract class AbstractContentWriter extends AbstractContentWriterLexical
|
|||
|
||||
/**
|
||||
* Creates an Lecical content writer for XML.
|
||||
*
|
||||
* @param out The writer to write to.
|
||||
*/
|
||||
public AbstractContentWriter(Writer out) {
|
||||
|
|
@ -45,6 +46,7 @@ public abstract class AbstractContentWriter extends AbstractContentWriterLexical
|
|||
|
||||
/**
|
||||
* Starts and end then element.
|
||||
*
|
||||
* @see org.x4o.sax3.io.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||
*/
|
||||
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
private String lastElement = null;
|
||||
private Stack<String> elements = null;
|
||||
|
||||
//@formatter:off
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "content/"; // TODO: change to "writer/xml"
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX + "output/encoding";
|
||||
|
|
@ -105,9 +106,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
new PropertyConfigItem(ROOT_START_NAMESPACE_ALL, Boolean.class, true)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public AbstractContentWriterHandler(Writer out) {
|
||||
|
|
@ -469,6 +472,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Starts the prefix mapping of an xml namespace uri.
|
||||
*
|
||||
* @param prefix The xml prefix of this xml namespace uri.
|
||||
* @param uri The xml namespace uri to add the prefix for.
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
|
|
@ -513,6 +517,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Escape and prints xml characters.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException When IOException has happend while printing.
|
||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||
|
|
@ -687,6 +692,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Auto close the start element if working in printing event.
|
||||
*
|
||||
* @throws SAXException When prints gives exception.
|
||||
*/
|
||||
protected void autoCloseStartElement() throws SAXException {
|
||||
|
|
@ -699,6 +705,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Indent the output writer with tabs by indent count.
|
||||
*
|
||||
* @throws SAXException When prints gives exception.
|
||||
*/
|
||||
private void writeIndent() throws SAXException {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public AbstractContentWriterLexical(Writer out) {
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Gets the attribute value.
|
||||
*
|
||||
* @param key The name of the attribute.
|
||||
* @return The value of the attribute.
|
||||
*/
|
||||
|
|
@ -273,8 +274,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an Set made of Map.Entry. note: This Map.Entry is not refenced by
|
||||
* the attribute list. so changes to not reflect to this map object.
|
||||
* Returns an Set made of Map.Entry. note: This Map.Entry is not refenced by the attribute list. so changes to not reflect to this map object.
|
||||
*
|
||||
* @see java.util.Map#entrySet()
|
||||
* @return An entry set.
|
||||
|
|
@ -320,6 +320,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Creates AttributeMapEntry with key object.
|
||||
*
|
||||
* @param key The key.
|
||||
*/
|
||||
protected AttributeMapEntry(Object key) {
|
||||
|
|
@ -335,6 +336,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Sets the value of this Map.Entry.
|
||||
*
|
||||
* @param value The value to set.
|
||||
* @return The old value.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ package org.x4o.sax3.io;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Functional closable callback for indenting api flow.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.xml.sax.ContentHandler;
|
|||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.LexicalHandler;
|
||||
|
||||
|
||||
/**
|
||||
* ContentWriter is ContentHandler for writing sax events.
|
||||
*
|
||||
|
|
@ -58,6 +57,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Starts and ends an element in one call.
|
||||
*
|
||||
* @param uri The uri of the element.
|
||||
* @param localName The localName of the element.
|
||||
* @param name The name of the element.
|
||||
|
|
@ -68,6 +68,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a String as xml comment.
|
||||
*
|
||||
* @param text The text to have embedded as comment in xml.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -75,6 +76,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a whitespace String to the body.
|
||||
*
|
||||
* @param text The String of whitespace to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -82,6 +84,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a whitespace character to the body.
|
||||
*
|
||||
* @param c The character to write.
|
||||
* @throws SAXException On error;
|
||||
*/
|
||||
|
|
@ -89,6 +92,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a String in the body.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -96,6 +100,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a single character in the body body.
|
||||
*
|
||||
* @param c The character to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.xml.sax.Attributes;
|
|||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
/**
|
||||
* ContentWriterAdapter is base ContentHandler for writing SAX3 events.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
|
||||
/**
|
||||
* Clones all the fields into the new PropertyConfigItem.
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -458,6 +459,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
|
||||
/**
|
||||
* Clones all the properties into the new PropertyConfig.
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public final class SAX3XMLConstants {
|
|||
|
||||
/**
|
||||
* Null or empty namespace uri.
|
||||
*
|
||||
* @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">Namespaces in XML, 5.2 Namespace Defaulting</a>
|
||||
*/
|
||||
public static final String NULL_NS_URI = javax.xml.XMLConstants.NULL_NS_URI; // ""
|
||||
|
|
@ -176,45 +177,106 @@ public final class SAX3XMLConstants {
|
|||
|
||||
static public boolean isChar(int c) {
|
||||
// Exclude "compatibility characters", as defined in section 2.3 of [Unicode]
|
||||
if (c>=0x7F & c<=0x84) { return false; }
|
||||
if (c>=0x86 & c<=0x9F) { return false; }
|
||||
if (c>=0xFDD0 & c<=0xFDEF) { return false; }
|
||||
if ((c>=0x1FFFE & c<=0x1FFFF)||(c>=0x2FFFE & c<=0x2FFFF)|(c>=0x3FFFE & c<=0x3FFFF)) { return false; }
|
||||
if ((c>=0x4FFFE & c<=0x4FFFF)||(c>=0x5FFFE & c<=0x5FFFF)|(c>=0x6FFFE & c<=0x6FFFF)) { return false; }
|
||||
if ((c>=0x7FFFE & c<=0x7FFFF)||(c>=0x8FFFE & c<=0x8FFFF)|(c>=0x9FFFE & c<=0x9FFFF)) { return false; }
|
||||
if ((c>=0xAFFFE & c<=0xAFFFF)||(c>=0xBFFFE & c<=0xBFFFF)|(c>=0xCFFFE & c<=0xCFFFF)) { return false; }
|
||||
if ((c>=0xDFFFE & c<=0xDFFFF)||(c>=0xEFFFE & c<=0xEFFFF)|(c>=0xFFFFE & c<=0xFFFFF)) { return false; }
|
||||
if (c>=0x10FFFE & c<=0x10FFFF) { return false; }
|
||||
if (c >= 0x7F & c <= 0x84) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0x86 & c <= 0x9F) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0xFDD0 & c <= 0xFDEF) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x1FFFE & c <= 0x1FFFF) || (c >= 0x2FFFE & c <= 0x2FFFF) | (c >= 0x3FFFE & c <= 0x3FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x4FFFE & c <= 0x4FFFF) || (c >= 0x5FFFE & c <= 0x5FFFF) | (c >= 0x6FFFE & c <= 0x6FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x7FFFE & c <= 0x7FFFF) || (c >= 0x8FFFE & c <= 0x8FFFF) | (c >= 0x9FFFE & c <= 0x9FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0xAFFFE & c <= 0xAFFFF) || (c >= 0xBFFFE & c <= 0xBFFFF) | (c >= 0xCFFFE & c <= 0xCFFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0xDFFFE & c <= 0xDFFFF) || (c >= 0xEFFFE & c <= 0xEFFFF) | (c >= 0xFFFFE & c <= 0xFFFFF)) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0x10FFFE & c <= 0x10FFFF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Source;
|
||||
// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
||||
if (c==0x9) { return true; }
|
||||
if (c==0xA) { return true; }
|
||||
if (c==0xD) { return true; }
|
||||
if (c>=0x20 & c<=0xD7FF) { return true; }
|
||||
if (c>=0xE000 & c<=0xFFFD) { return true; }
|
||||
if (c>=0x10000 & c<=0x10FFFF) { return true; }
|
||||
if (c == 0x9) {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xA) {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x20 & c <= 0xD7FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xE000 & c <= 0xFFFD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x10000 & c <= 0x10FFFF) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean isNameStartChar(int c) {
|
||||
// Source;
|
||||
// ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
if (c>='a' & c<='z') { return true; }
|
||||
if (c>='A' & c<='Z') { return true; }
|
||||
if (c==':' || c=='_') { return true; }
|
||||
if (c>=0xC0 & c<=0xD6) { return true; }
|
||||
if (c>=0xD8 & c<=0xF6) { return true; }
|
||||
if (c>=0xF8 & c<=0x2FF) { return true; }
|
||||
if (c>=0x370 & c<=0x37D) { return true; }
|
||||
if (c>=0x37F & c<=0x1FFF) { return true; }
|
||||
if (c>=0x200C & c<=0x200D) { return true; }
|
||||
if (c>=0x2070 & c<=0x218F) { return true; }
|
||||
if (c>=0x2C00 & c<=0x2FEF) { return true; }
|
||||
if (c>=0x3001 & c<=0xD7FF) { return true; }
|
||||
if (c>=0xF900 & c<=0xFDCF) { return true; }
|
||||
if (c>=0xFDF0 & c<=0xFFFD) { return true; }
|
||||
if (c>=0x10000 & c<=0xEFFFF) { return true; }
|
||||
// ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
|
||||
// [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
if (c >= 'a' & c <= 'z') {
|
||||
return true;
|
||||
}
|
||||
if (c >= 'A' & c <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
if (c == ':' || c == '_') {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xC0 & c <= 0xD6) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xD8 & c <= 0xF6) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xF8 & c <= 0x2FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x370 & c <= 0x37D) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x37F & c <= 0x1FFF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x200C & c <= 0x200D) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x2070 & c <= 0x218F) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x2C00 & c <= 0x2FEF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x3001 & c <= 0xD7FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xF900 & c <= 0xFDCF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xFDF0 & c <= 0xFFFD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x10000 & c <= 0xEFFFF) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -224,11 +286,21 @@ public final class SAX3XMLConstants {
|
|||
if (isNameStartChar(c)) {
|
||||
return true;
|
||||
}
|
||||
if (c=='-' || c=='.') { return true; }
|
||||
if (c>='0' & c<='9') { return true; }
|
||||
if (c==0xB7) { return true; }
|
||||
if (c>=0x0300 & c<=0x036F) { return true; }
|
||||
if (c>=0x203F & c<=0x2040) { return true; }
|
||||
if (c == '-' || c == '.') {
|
||||
return true;
|
||||
}
|
||||
if (c >= '0' & c <= '9') {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xB7) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x0300 & c <= 0x036F) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x203F & c <= 0x2040) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -357,35 +429,85 @@ public final class SAX3XMLConstants {
|
|||
}
|
||||
|
||||
// XML
|
||||
if ("<".equals(entity)) { return true; }
|
||||
if (">".equals(entity)) { return true; }
|
||||
if ("&".equals(entity)) { return true; }
|
||||
if (""".equals(entity)) { return true; }
|
||||
if ("'".equals(entity)) { return true; }
|
||||
if ("<".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if (">".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("&".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if (""".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("'".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// HTML
|
||||
if ("´".equals(entity)) { return true; }
|
||||
if ("ℵ".equals(entity)) { return true; }
|
||||
if ("≈".equals(entity)) { return true; }
|
||||
if ("∠".equals(entity)) { return true; }
|
||||
if ("∗".equals(entity)) { return true; }
|
||||
if ("♣".equals(entity)) { return true; }
|
||||
if ("♦".equals(entity)) { return true; }
|
||||
if ("♥".equals(entity)) { return true; }
|
||||
if ("♠".equals(entity)) { return true; }
|
||||
if ("´".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("ℵ".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("≈".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("∠".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("∗".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("♣".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("♦".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("♥".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("♠".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
// TODO: etc/etc
|
||||
if ("ÿ".equals(entity)) { return true; }
|
||||
if ("ý".equals(entity)) { return true; }
|
||||
if ("ù".equals(entity)) { return true; }
|
||||
if ("ü".equals(entity)) { return true; }
|
||||
if ("û".equals(entity)) { return true; }
|
||||
if ("ú".equals(entity)) { return true; }
|
||||
if ("ÿ".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("ý".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("ù".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("ü".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("û".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("ú".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("÷".equals(entity)) { return true; }
|
||||
if (" ".equals(entity)) { return true; }
|
||||
if ("®".equals(entity)) { return true; }
|
||||
if ("™".equals(entity)) { return true; }
|
||||
if ("©".equals(entity)) { return true; }
|
||||
if ("÷".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if (" ".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("®".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("™".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("©".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public abstract class AbstractXDBXWriter extends AbstractXDBXWriterLexical imple
|
|||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriter(OutputStream out) {
|
||||
|
|
@ -46,6 +47,7 @@ public abstract class AbstractXDBXWriter extends AbstractXDBXWriterLexical imple
|
|||
|
||||
/**
|
||||
* Starts and end then element.
|
||||
*
|
||||
* @see org.x4o.sax3.io.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||
*/
|
||||
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
private Stack<String> elements = null;
|
||||
private Map<String, Integer> stringIdx = null;
|
||||
|
||||
//@formatter:off
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/xdbx/";
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
public final static String OUTPUT_DECLARATION = PROPERTY_CONTEXT_PREFIX+"output/declaration";
|
||||
|
|
@ -94,9 +95,11 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
new PropertyConfigItem(ROOT_START_NAMESPACE_ALL, Boolean.class, true)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriterHandler(OutputStream out) {
|
||||
|
|
@ -423,6 +426,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Starts the prefix mapping of an xml namespace uri.
|
||||
*
|
||||
* @param prefix The xml prefix of this xml namespace uri.
|
||||
* @param uri The xml namespace uri to add the prefix for.
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
|
|
@ -479,6 +483,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Escape and prints xml characters.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException When IOException has happend while printing.
|
||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
|||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriterLexical(OutputStream out) {
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ public enum XDBXContentTag {
|
|||
PROCESSING_INSTRUCTION('P'),
|
||||
STRING_ID('I'),
|
||||
HINT('H'),
|
||||
SEQUENCE_SEPERATOR('@'),
|
||||
;
|
||||
SEQUENCE_SEPERATOR('@'),;
|
||||
|
||||
private final int tagNumber;
|
||||
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ public class XDBXReaderXml {
|
|||
XDBXElement() {
|
||||
atts = new AttributesImpl();
|
||||
}
|
||||
|
||||
XDBXElement(String localName) {
|
||||
this();
|
||||
this.localName = localName;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class XDBXWriterXml extends AbstractXDBXWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
*/
|
||||
public XDBXWriterXml(OutputStream out) {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,9 @@ public class SAX3WriterXmlAttributeTest {
|
|||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test attr=\"<test/> & 'foobar' is "quoted"!\"/>"), output);
|
||||
Assertions.assertTrue(
|
||||
output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test attr=\"<test/> & 'foobar' is "quoted"!\"/>"),
|
||||
output);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -153,7 +155,9 @@ public class SAX3WriterXmlAttributeTest {
|
|||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test ๐ณ๐๐ฎ๐บ๐๐๐ค๐๐ญ๐๐ก๐ช๐ธ๐=\"๐ณ๐๐ฎ๐บ๐๐๐ค๐๐ญ๐๐ก๐ช๐ธ๐\" แกแขแแปแปแซแฟ=\"แกแขแแปแปแซแฟ\"/>"), output);
|
||||
Assertions.assertTrue(output.equals(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test ๐ณ๐๐ฎ๐บ๐๐๐ค๐๐ญ๐๐ก๐ช๐ธ๐=\"๐ณ๐๐ฎ๐บ๐๐๐ค๐๐ญ๐๐ก๐ช๐ธ๐\" แกแขแแปแปแซแฟ=\"แกแขแแปแปแซแฟ\"/>"),
|
||||
output);
|
||||
|
||||
// TODO: fix SAX impl
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ public class SAX3WriterXmlTest {
|
|||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test>\n\t<?target-doc data-doc?>\n</test>\n"), output);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test>\n\t<?target-doc data-doc?>\n</test>\n"),
|
||||
output);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ public class XDBXWriterXmlTest {
|
|||
Assertions.assertEquals((byte) 'Z', output[outIdx++]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExample3StringIds() throws Exception {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
|
|
|||
Loadingโฆ
Add table
Add a link
Reference in a new issue