/** * Actually load the specified document using the configured DocumentLoader. * @param inputSource the SAX InputSource to read from * @param resource the resource descriptor for the XML file * @return the DOM Document * @throws Exception when thrown from the DocumentLoader * @see #setDocumentLoader * @see DocumentLoader#loadDocument */ protected Document doLoadDocument(InputSource inputSource, Resource resource) throws Exception { return this.documentLoader.loadDocument(inputSource, getEntityResolver(), this.errorHandler, getValidationModeForResource(resource), isNamespaceAware()); }
/** * Actually load the specified document using the configured DocumentLoader. * @param inputSource the SAX InputSource to read from * @param resource the resource descriptor for the XML file * @return the DOM Document * @throws Exception when thrown from the DocumentLoader * @see #setDocumentLoader * @see DocumentLoader#loadDocument */ protected Document doLoadDocument(InputSource inputSource, Resource resource) throws Exception { return this.documentLoader.loadDocument(inputSource, getEntityResolver(), this.errorHandler, getValidationModeForResource(resource), isNamespaceAware()); }
private Document getDocument(String location) { InputStream inputStream = this.getClass().getResourceAsStream(location); try { return documentLoader.loadDocument(new InputSource(inputStream), new DelegatingEntityResolver(getClass().getClassLoader()), errorHandler, 0, true); } catch (Exception e) { throw new RuntimeException(e); } finally { try { inputStream.close(); } catch (IOException e) { } } }
try { int validationMode = getValidationModeForResource(resource); Document doc = this.documentLoader.loadDocument( inputSource, getEntityResolver(), this.errorHandler, validationMode, isNamespaceAware()); return registerBeanDefinitions(doc, resource);
/** * Load the {@link Document} at the supplied {@link InputSource} using the standard JAXP-configured XML parser. */ @Override public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); IOUtils.copy(inputSource.getByteStream(), output); InputSource defaultInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); InputSource enrichInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); Document doc = defaultLoader.loadDocument(defaultInputSource, entityResolver, errorHandler, validationMode, namespaceAware); createSaxAnnotator(doc).parse(enrichInputSource); return doc; }
/** * Load the {@link Document} at the supplied {@link InputSource} using the standard JAXP-configured XML parser. */ @Override public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); try (InputStream inputStream = inputSource.getByteStream()) { IOUtils.copy(inputStream, output); } InputSource defaultInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); InputSource enrichInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); Document doc = defaultLoader.loadDocument(defaultInputSource, entityResolver, errorHandler, validationMode, namespaceAware); createSaxAnnotator(doc).parse(enrichInputSource); return doc; }
/** * Load the {@link Document} at the supplied {@link InputSource} using the standard JAXP-configured XML parser. */ @Override public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); try (InputStream inputStream = inputSource.getByteStream()) { IOUtils.copy(inputStream, output); } InputSource defaultInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); InputSource enrichInputSource = new InputSource(new ByteArrayInputStream(output.toByteArray())); Document doc = defaultLoader.loadDocument(defaultInputSource, entityResolver, errorHandler, validationMode, namespaceAware); createSaxAnnotator(doc).parse(enrichInputSource); return doc; }
InputSource inputSource = new InputSource(resource.getInputStream()); inputSource.setEncoding(encoding); Document doc = documentLoader.loadDocument(inputSource, entityResolver, errorHandler, XmlValidationModeDetector.VALIDATION_XSD, false); final List<Element> sqes = DomUtils.getChildElementsByTagName(doc.getDocumentElement(), "sql");
public Document readDocument() { try { InputSource source = new InputSource(resource.getInputStream()); return loader.loadDocument(source, getEntityResolver(), errorHandler, getValidationMode(), true); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new DocumentReaderException(resource, e); } }
/** * Returns the <code>localRepository</code> settings as indicated by the * <code>settings.xml</code> file. * * @return local repository as indicated by a Maven settings.xml file */ String getMavenSettingsLocalRepository(Resource m2Settings) { // no file found, return null to continue the discovery process if (!m2Settings.exists()) return null; try { DocumentLoader docLoader = new DefaultDocumentLoader(); Document document = docLoader.loadDocument(new InputSource(m2Settings.getInputStream()), null, null, XmlValidationModeDetector.VALIDATION_NONE, false); return (DomUtils.getChildElementValueByTagName(document.getDocumentElement(), LOCAL_REPOSITORY_ELEM)); } catch (Exception ex) { throw (RuntimeException) new RuntimeException(new ParserConfigurationException("error parsing resource=" + m2Settings).initCause(ex)); } }
/** * Actually load the specified document using the configured DocumentLoader. * @param inputSource the SAX InputSource to read from * @param resource the resource descriptor for the XML file * @return the DOM Document * @throws Exception when thrown from the DocumentLoader * @see #setDocumentLoader * @see DocumentLoader#loadDocument */ protected Document doLoadDocument(InputSource inputSource, Resource resource) throws Exception { return this.documentLoader.loadDocument(inputSource, getEntityResolver(), this.errorHandler, getValidationModeForResource(resource), isNamespaceAware()); }
/** * Returns the <tt>groupId</tt> setting in a <tt>pom.xml</tt> file. * * @return a <tt>pom.xml</tt> <tt>groupId</tt>. */ String getGroupIdFromPom(Resource pomXml) { try { DocumentLoader docLoader = new DefaultDocumentLoader(); Document document = docLoader.loadDocument(new InputSource(pomXml.getInputStream()), null, null, XmlValidationModeDetector.VALIDATION_NONE, false); String groupId = DomUtils.getChildElementValueByTagName(document.getDocumentElement(), GROUP_ID_ELEM); // no groupId specified, try the parent definition if (groupId == null) { if (log.isTraceEnabled()) log.trace("No groupId defined; checking for the parent definition"); Element parent = DomUtils.getChildElementByTagName(document.getDocumentElement(), "parent"); if (parent != null) return DomUtils.getChildElementValueByTagName(parent, GROUP_ID_ELEM); } else { return groupId; } } catch (Exception ex) { throw (RuntimeException) new RuntimeException(new ParserConfigurationException("error parsing resource=" + pomXml).initCause(ex)); } throw new IllegalArgumentException("no groupId or parent/groupId defined by resource [" + pomXml.getDescription() + "]"); }