protected List<NotationDeclaration> getNotationDecls() {
if (fEventType == XMLStreamConstants.DTD) {
if (fScanner.fDTDScanner == null) {
return null;
}
DTDGrammar grammar = ((XMLDTDScannerImpl) (fScanner.fDTDScanner)).getGrammar();
if (grammar == null) {
return null;
}
List<XMLNotationDecl> notations = grammar.getNotationDecls();
ArrayList<NotationDeclaration> list = new ArrayList<>();
for (XMLNotationDecl notation : notations) {
if (notation != null) {
list.add(new NotationDeclarationImpl(notation));
}
}
return list;
}
return null;
}
java类javax.xml.stream.events.NotationDeclaration的实例源码
XMLStreamReaderImpl.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 16
收藏 0
点赞 0
评论 0
private DTDSubsetImpl(boolean cachable,
HashMap<String,EntityDecl> genEnt, Set<String> refdGEs,
HashMap<String,EntityDecl> paramEnt, Set<String> peRefs,
HashMap<String,NotationDeclaration> notations, HashMap<PrefixedName,DTDElement> elements,
boolean fullyValidating)
{
mIsCachable = cachable;
mGeneralEntities = genEnt;
mRefdGEs = refdGEs;
mDefinedPEs = paramEnt;
mRefdPEs = peRefs;
mNotations = notations;
mElements = elements;
mFullyValidating = fullyValidating;
boolean anyNsDefs = false;
if (elements != null) {
for (DTDElement elem : elements.values()) {
if (elem.hasNsDefaults()) {
anyNsDefs = true;
break;
}
}
}
mHasNsDefaults = anyNsDefs;
}
Issue48Test.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
/**
* DTDEvent instances constructed via event reader are missing the notation
* and entity declaration information
*/
@Test
public void testDTDEvent() {
String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
+ "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
+ "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";
try {
XMLEventReader er = getReader(XML);
XMLEvent evt = er.nextEvent(); // StartDocument
evt = er.nextEvent(); // DTD
if (evt.getEventType() != XMLStreamConstants.DTD) {
Assert.fail("Expected DTD event");
}
DTD dtd = (DTD) evt;
List entities = dtd.getEntities();
if (entities == null) {
Assert.fail("No entity found. Expected 3.");
} else {
Assert.assertEquals(entities.size(), 3);
}
// Let's also verify they are all of right type...
testListElems(entities, EntityDeclaration.class);
List notations = dtd.getNotations();
if (notations == null) {
Assert.fail("No notation found. Expected 2.");
} else {
Assert.assertEquals(notations.size(), 2);
}
// Let's also verify they are all of right type...
testListElems(notations, NotationDeclaration.class);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Issue48Test.java 文件源码
项目:openjdk9
阅读 24
收藏 0
点赞 0
评论 0
/**
* DTDEvent instances constructed via event reader are missing the notation
* and entity declaration information
*/
@Test
public void testDTDEvent() {
String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
+ "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
+ "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";
try {
XMLEventReader er = getReader(XML);
XMLEvent evt = er.nextEvent(); // StartDocument
evt = er.nextEvent(); // DTD
if (evt.getEventType() != XMLStreamConstants.DTD) {
Assert.fail("Expected DTD event");
}
DTD dtd = (DTD) evt;
List entities = dtd.getEntities();
if (entities == null) {
Assert.fail("No entity found. Expected 3.");
} else {
Assert.assertEquals(entities.size(), 3);
}
// Let's also verify they are all of right type...
testListElems(entities, EntityDeclaration.class);
List notations = dtd.getNotations();
if (notations == null) {
Assert.fail("No notation found. Expected 2.");
} else {
Assert.assertEquals(notations.size(), 2);
}
// Let's also verify they are all of right type...
testListElems(notations, NotationDeclaration.class);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
WDTD.java 文件源码
项目:woodstox
阅读 17
收藏 0
点赞 0
评论 0
@Override
public List<NotationDeclaration> getNotations() {
if (mNotations == null && (mSubset != null)) {
mNotations = new ArrayList<NotationDeclaration>(mSubset.getNotationList());
}
return mNotations;
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 16
收藏 0
点赞 0
评论 0
public static DTDSubsetImpl constructInstance(boolean cachable,
HashMap<String,EntityDecl> genEnt, Set<String> refdGEs,
HashMap<String,EntityDecl> paramEnt, Set<String> refdPEs,
HashMap<String,NotationDeclaration> notations,
HashMap<PrefixedName,DTDElement> elements,
boolean fullyValidating)
{
return new DTDSubsetImpl(cachable, genEnt, refdGEs,
paramEnt, refdPEs,
notations, elements,
fullyValidating);
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 17
收藏 0
点赞 0
评论 0
@Override
public synchronized List<NotationDeclaration> getNotationList()
{
List<NotationDeclaration> l = mNotationList;
if (l == null) {
if (mNotations == null || mNotations.size() == 0) {
l = Collections.emptyList();
} else {
l = Collections.unmodifiableList(new ArrayList<NotationDeclaration>(mNotations.values()));
}
mNotationList = l;
}
return l;
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 16
收藏 0
点赞 0
评论 0
public static void throwNotationException(NotationDeclaration oldDecl, NotationDeclaration newDecl)
throws XMLStreamException
{
throw new WstxParsingException
(MessageFormat.format(ErrorConsts.ERR_DTD_NOTATION_REDEFD,
new Object[] {
newDecl.getName(),
oldDecl.getLocation().toString()}),
newDecl.getLocation());
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 21
收藏 0
点赞 0
评论 0
private static void checkNotations(HashMap<String,NotationDeclaration> fromInt, HashMap<String,NotationDeclaration> fromExt)
throws XMLStreamException
{
/* Since it's external subset that would try to redefine things
* defined in internal subset, let's traverse definitions in
* the ext. subset first (even though that may not be the fastest
* way), so that we have a chance of catching the first problem
* (As long as Maps iterate in insertion order).
*/
for (Map.Entry<String, NotationDeclaration> en : fromExt.entrySet()) {
if (fromInt.containsKey(en.getKey())) {
throwNotationException(fromInt.get(en.getKey()), en.getValue());
}
}
}
TestDoctypeDecl.java 文件源码
项目:woodstox
阅读 23
收藏 0
点赞 0
评论 0
public void testSimpleNotation()
throws XMLStreamException
{
XMLStreamReader sr = getReader(UNPARSED_ENTITY_XML, true);
assertTokenType(DTD, sr.next());
List<?> l = (List<?>) sr.getProperty("javax.xml.stream.notations");
assertNotNull(l);
assertEquals(1, l.size());
NotationDeclaration nd = (NotationDeclaration) l.get(0);
assertEquals("mynot", nd.getName());
}
DTDEvent.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public void setNotations(List<NotationDeclaration> notations) {
fNotations = notations;
}
DTDEvent.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
@Override
public List<NotationDeclaration> getNotations() {
return fNotations;
}
StaxEventXMLReader.java 文件源码
项目:spring4-understanding
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
boolean documentStarted = false;
boolean documentEnded = false;
int elementDepth = 0;
while (this.reader.hasNext() && elementDepth >= 0) {
XMLEvent event = this.reader.nextEvent();
if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
handleStartDocument(event);
documentStarted = true;
}
switch (event.getEventType()) {
case XMLStreamConstants.START_DOCUMENT:
handleStartDocument(event);
documentStarted = true;
break;
case XMLStreamConstants.START_ELEMENT:
elementDepth++;
handleStartElement(event.asStartElement());
break;
case XMLStreamConstants.END_ELEMENT:
elementDepth--;
if (elementDepth >= 0) {
handleEndElement(event.asEndElement());
}
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
handleProcessingInstruction((ProcessingInstruction) event);
break;
case XMLStreamConstants.CHARACTERS:
case XMLStreamConstants.SPACE:
case XMLStreamConstants.CDATA:
handleCharacters(event.asCharacters());
break;
case XMLStreamConstants.END_DOCUMENT:
handleEndDocument();
documentEnded = true;
break;
case XMLStreamConstants.NOTATION_DECLARATION:
handleNotationDeclaration((NotationDeclaration) event);
break;
case XMLStreamConstants.ENTITY_DECLARATION:
handleEntityDeclaration((EntityDeclaration) event);
break;
case XMLStreamConstants.COMMENT:
handleComment((Comment) event);
break;
case XMLStreamConstants.DTD:
handleDtd((DTD) event);
break;
case XMLStreamConstants.ENTITY_REFERENCE:
handleEntityReference((EntityReference) event);
break;
}
}
if (documentStarted && !documentEnded) {
handleEndDocument();
}
}
StaxEventXMLReader.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
if (getDTDHandler() != null) {
getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
}
}
StaxEventXMLReader.java 文件源码
项目:spring
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
boolean documentStarted = false;
boolean documentEnded = false;
int elementDepth = 0;
while (this.reader.hasNext() && elementDepth >= 0) {
XMLEvent event = this.reader.nextEvent();
if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
handleStartDocument(event);
documentStarted = true;
}
switch (event.getEventType()) {
case XMLStreamConstants.START_DOCUMENT:
handleStartDocument(event);
documentStarted = true;
break;
case XMLStreamConstants.START_ELEMENT:
elementDepth++;
handleStartElement(event.asStartElement());
break;
case XMLStreamConstants.END_ELEMENT:
elementDepth--;
if (elementDepth >= 0) {
handleEndElement(event.asEndElement());
}
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
handleProcessingInstruction((ProcessingInstruction) event);
break;
case XMLStreamConstants.CHARACTERS:
case XMLStreamConstants.SPACE:
case XMLStreamConstants.CDATA:
handleCharacters(event.asCharacters());
break;
case XMLStreamConstants.END_DOCUMENT:
handleEndDocument();
documentEnded = true;
break;
case XMLStreamConstants.NOTATION_DECLARATION:
handleNotationDeclaration((NotationDeclaration) event);
break;
case XMLStreamConstants.ENTITY_DECLARATION:
handleEntityDeclaration((EntityDeclaration) event);
break;
case XMLStreamConstants.COMMENT:
handleComment((Comment) event);
break;
case XMLStreamConstants.DTD:
handleDtd((DTD) event);
break;
case XMLStreamConstants.ENTITY_REFERENCE:
handleEntityReference((EntityReference) event);
break;
}
}
if (documentStarted && !documentEnded) {
handleEndDocument();
}
}
StaxEventXMLReader.java 文件源码
项目:spring
阅读 24
收藏 0
点赞 0
评论 0
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
if (getDTDHandler() != null) {
getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
}
}
StaxEventXMLReader.java 文件源码
项目:class-guard
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
boolean documentStarted = false;
boolean documentEnded = false;
int elementDepth = 0;
while (this.reader.hasNext() && elementDepth >= 0) {
XMLEvent event = this.reader.nextEvent();
if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
handleStartDocument(event);
documentStarted = true;
}
switch (event.getEventType()) {
case XMLStreamConstants.START_DOCUMENT:
handleStartDocument(event);
documentStarted = true;
break;
case XMLStreamConstants.START_ELEMENT:
elementDepth++;
handleStartElement(event.asStartElement());
break;
case XMLStreamConstants.END_ELEMENT:
elementDepth--;
if (elementDepth >= 0) {
handleEndElement(event.asEndElement());
}
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
handleProcessingInstruction((ProcessingInstruction) event);
break;
case XMLStreamConstants.CHARACTERS:
case XMLStreamConstants.SPACE:
case XMLStreamConstants.CDATA:
handleCharacters(event.asCharacters());
break;
case XMLStreamConstants.END_DOCUMENT:
handleEndDocument();
documentEnded = true;
break;
case XMLStreamConstants.NOTATION_DECLARATION:
handleNotationDeclaration((NotationDeclaration) event);
break;
case XMLStreamConstants.ENTITY_DECLARATION:
handleEntityDeclaration((EntityDeclaration) event);
break;
case XMLStreamConstants.COMMENT:
handleComment((Comment) event);
break;
case XMLStreamConstants.DTD:
handleDtd((DTD) event);
break;
case XMLStreamConstants.ENTITY_REFERENCE:
handleEntityReference((EntityReference) event);
break;
}
}
if (documentStarted && !documentEnded) {
handleEndDocument();
}
}
StaxEventXMLReader.java 文件源码
项目:class-guard
阅读 21
收藏 0
点赞 0
评论 0
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
if (getDTDHandler() != null) {
getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
}
}
FullDTDReader.java 文件源码
项目:woodstox
阅读 16
收藏 0
点赞 0
评论 0
/**
* Common initialization part of int/ext subset constructors.
*/
private FullDTDReader(WstxInputSource input, ReaderConfig cfg,
boolean isExt, DTDSubset intSubset,
boolean constructFully, int xmlVersion)
{
super(input, cfg, isExt);
/* What matters here is what the main xml doc had; that determines
* xml conformance level to use.
*/
mDocXmlVersion = xmlVersion;
mXml11 = cfg.isXml11();
int cfgFlags = cfg.getConfigFlags();
mConfigFlags = cfgFlags;
mCfgSupportDTDPP = (cfgFlags & CFG_SUPPORT_DTDPP) != 0;
mCfgFullyValidating = constructFully;
mUsesPredefdEntities = false;
mParamEntities = null;
mRefdPEs = null;
mRefdGEs = null;
mGeneralEntities = null;
// Did we get any existing parameter entities?
HashMap<String,EntityDecl> pes = (intSubset == null) ?
null : intSubset.getParameterEntityMap();
if (pes == null || pes.isEmpty()) {
mPredefdPEs = null;
} else {
mPredefdPEs = pes;
}
// How about general entities (needed only for attr. def. values)
HashMap<String,EntityDecl> ges = (intSubset == null) ?
null : intSubset.getGeneralEntityMap();
if (ges == null || ges.isEmpty()) {
mPredefdGEs = null;
} else {
mPredefdGEs = ges;
}
// And finally, notations
HashMap<String,NotationDeclaration> not = (intSubset == null) ?
null : intSubset.getNotationMap();
if (not == null || not.isEmpty()) {
mPredefdNotations = null;
} else {
mPredefdNotations = not;
}
mEventListener = mConfig.getDTDEventListener();
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 16
收藏 0
点赞 0
评论 0
/**
* Method that will combine definitions from internal and external subsets,
* producing a single DTD set.
*/
@Override
public DTDSubset combineWithExternalSubset(InputProblemReporter rep, DTDSubset extSubset)
throws XMLStreamException
{
/* First let's see if we can just reuse GE Map used by int or ext
* subset; (if only one has contents), or if not, combine them.
*/
HashMap<String,EntityDecl> ge1 = getGeneralEntityMap();
HashMap<String,EntityDecl> ge2 = extSubset.getGeneralEntityMap();
if (ge1 == null || ge1.isEmpty()) {
ge1 = ge2;
} else {
if (ge2 != null && !ge2.isEmpty()) {
/* Internal subset Objects are never shared or reused (and by
* extension, neither are objects they contain), so we can just
* modify GE map if necessary
*/
combineMaps(ge1, ge2);
}
}
// Ok, then, let's combine notations similarly
HashMap<String,NotationDeclaration> n1 = getNotationMap();
HashMap<String,NotationDeclaration> n2 = extSubset.getNotationMap();
if (n1 == null || n1.isEmpty()) {
n1 = n2;
} else {
if (n2 != null && !n2.isEmpty()) {
/* First; let's make sure there are no colliding notation
* definitions: it's an error to try to redefine notations.
*/
checkNotations(n1, n2);
/* Internal subset Objects are never shared or reused (and by
* extension, neither are objects they contain), so we can just
* modify notation map if necessary
*/
combineMaps(n1, n2);
}
}
// And finally elements, rather similarly:
HashMap<PrefixedName,DTDElement> e1 = getElementMap();
HashMap<PrefixedName,DTDElement> e2 = extSubset.getElementMap();
if (e1 == null || e1.isEmpty()) {
e1 = e2;
} else {
if (e2 != null && !e2.isEmpty()) {
/* Internal subset Objects are never shared or reused (and by
* extension, neither are objects they contain), so we can just
* modify element map if necessary
*/
combineElements(rep, e1, e2);
}
}
/* Combos are not cachable, and because of that, there's no point
* in storing any PE info either.
*/
return constructInstance(false, ge1, null, null, null, n1, e1,
mFullyValidating);
}
DTDSubsetImpl.java 文件源码
项目:woodstox
阅读 18
收藏 0
点赞 0
评论 0
@Override
public HashMap<String,NotationDeclaration> getNotationMap() {
return mNotations;
}
DTDSubset.java 文件源码
项目:woodstox
阅读 15
收藏 0
点赞 0
评论 0
public abstract HashMap<String,NotationDeclaration> getNotationMap();
DTDSubset.java 文件源码
项目:woodstox
阅读 15
收藏 0
点赞 0
评论 0
public abstract List<NotationDeclaration> getNotationList();