javax.xml.stream.events.NotationDeclaration Java Examples
The following examples show how to use
javax.xml.stream.events.NotationDeclaration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLStreamReaderImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: XMLStreamReaderImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example #3
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: TestDoctypeDecl.java From woodstox with Apache License 2.0 | 5 votes |
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()); }
Example #5
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 5 votes |
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()); } } }
Example #6
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 5 votes |
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()); }
Example #7
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 5 votes |
@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; }
Example #8
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 5 votes |
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); }
Example #9
Source File: Issue48Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example #10
Source File: WDTD.java From woodstox with Apache License 2.0 | 5 votes |
@Override public List<NotationDeclaration> getNotations() { if (mNotations == null && (mSubset != null)) { mNotations = new ArrayList<NotationDeclaration>(mSubset.getNotationList()); } return mNotations; }
Example #11
Source File: StaxEventXMLReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException { if (getDTDHandler() != null) { getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId()); } }
Example #12
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 4 votes |
@Override public HashMap<String,NotationDeclaration> getNotationMap() { return mNotations; }
Example #13
Source File: DTDSubsetImpl.java From woodstox with Apache License 2.0 | 4 votes |
/** * 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); }
Example #14
Source File: FullDTDReader.java From woodstox with Apache License 2.0 | 4 votes |
/** * 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(); }
Example #15
Source File: StaxEventXMLReader.java From spring-analysis-note with MIT License | 4 votes |
@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(); } }
Example #16
Source File: StaxEventXMLReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
@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(); } }
Example #17
Source File: DTDEvent.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public List<NotationDeclaration> getNotations() { return fNotations; }
Example #18
Source File: DTDEvent.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void setNotations(List<NotationDeclaration> notations) { fNotations = notations; }
Example #19
Source File: DTDEvent.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override public List<NotationDeclaration> getNotations() { return fNotations; }
Example #20
Source File: DTDEvent.java From Bytecoder with Apache License 2.0 | 4 votes |
public void setNotations(List<NotationDeclaration> notations) { fNotations = notations; }
Example #21
Source File: StaxEventXMLReader.java From lams with GNU General Public License v2.0 | 4 votes |
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException { if (getDTDHandler() != null) { getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId()); } }
Example #22
Source File: StaxEventXMLReader.java From lams with GNU General Public License v2.0 | 4 votes |
@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(); } }
Example #23
Source File: StaxEventXMLReader.java From java-technology-stack with MIT License | 4 votes |
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException { if (getDTDHandler() != null) { getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId()); } }
Example #24
Source File: StaxEventXMLReader.java From java-technology-stack with MIT License | 4 votes |
@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(); } }
Example #25
Source File: StaxEventXMLReader.java From spring-analysis-note with MIT License | 4 votes |
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException { if (getDTDHandler() != null) { getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId()); } }
Example #26
Source File: XmlUtils.java From entity-fishing with Apache License 2.0 | 2 votes |
/** * Compares two {@link XMLEvent} instances. This method delegates actual * matching to the appropriate overloaded method. * * @param a * The first event. * @param b * The second event. * @return <code>true</code> if the events match, <code>false</code> * otherwise. */ public static boolean eventsMatch(XMLEvent a, XMLEvent b) { if (a == b) { return true; } else if (a == null || b == null) { return false; } else if (a.getEventType() == b.getEventType()) { switch (a.getEventType()) { case XMLEvent.START_ELEMENT: return eventsMatch(a.asStartElement(), b.asStartElement()); case XMLEvent.END_ELEMENT: return eventsMatch(a.asEndElement(), b.asEndElement()); case XMLEvent.CDATA: case XMLEvent.SPACE: case XMLEvent.CHARACTERS: return eventsMatch(a.asCharacters(), b.asCharacters()); case XMLEvent.COMMENT: return eventsMatch((Comment) a, (Comment) b); case XMLEvent.ENTITY_REFERENCE: return eventsMatch((EntityReference) a, (EntityReference) b); case XMLEvent.ATTRIBUTE: return eventsMatch((Attribute) a, (Attribute) b); case XMLEvent.NAMESPACE: return eventsMatch((Namespace) a, (Namespace) b); case XMLEvent.START_DOCUMENT: return eventsMatch((StartDocument) a, (StartDocument) b); case XMLEvent.END_DOCUMENT: return eventsMatch((EndDocument) a, (EndDocument) b); case XMLEvent.PROCESSING_INSTRUCTION: return eventsMatch((ProcessingInstruction) a, (ProcessingInstruction) b); case XMLEvent.DTD: return eventsMatch((DTD) a, (DTD) b); case XMLEvent.ENTITY_DECLARATION: return eventsMatch((EntityDeclaration) a, (EntityDeclaration) b); case XMLEvent.NOTATION_DECLARATION: return eventsMatch((NotationDeclaration) a, (NotationDeclaration) b); } } return false; }
Example #27
Source File: DTDSubset.java From woodstox with Apache License 2.0 | votes |
public abstract HashMap<String,NotationDeclaration> getNotationMap();
Example #28
Source File: DTDSubset.java From woodstox with Apache License 2.0 | votes |
public abstract List<NotationDeclaration> getNotationList();