/** * Creates a non pooling Parser, with the given options. * * @param options * the options. * @return DOMParser. */ public static DOMParser createNonPoolingParser(final DOMParserOptions options) { return new NonPoolingDOMParser(options != null ? options : DOMParserOptions.getDefault()); }
public DefaultPDPProxy(final InputStream rightsDocument) { if (rightsDocument == null) { throw new IllegalArgumentException("parameter <rightsDocument> must not null"); } m_rightsDocument = DOMParser.createNew(DOMParserOptions.getDefault().notNamespaceaware()).parse( new InputSource(rightsDocument)); }
/** * Creates a pooling Parser with the given options, using the global DocumentBuilder pool. * * @param options * the options. * @return DOMParser. */ public static DOMParser createPoolingParser(final DOMParserOptions options) { return new PoolingDOMParser(options != null ? options : DOMParserOptions.getDefault(), getDocumentBuilderPool()); }
/** * Creates a pooling Parser with the given options, which uses the given document builder pool. * * @return DOMParser. */ public static DOMParser createPoolingParser(final DOMParserOptions options, final DocumentBuilderPool pool) { return new PoolingDOMParser(options != null ? options : DOMParserOptions.getDefault(), pool != null ? pool : getDocumentBuilderPool()); }
public Document asXmlDocument(Locale userLocale) { String[] parts = getPathToXmlTree().split("\\."); StringBuilder localizedName = new StringBuilder(); localizedName.append(parts[0]); localizedName.append("_"); localizedName.append(userLocale.getLanguage()); localizedName.append("."); localizedName.append(parts[1]); Document treeDoc = DOMUtil.createDocumentFromSystemID(localizedName.toString(), DOMParserOptions.getDefault().notNamespaceaware()); if (treeDoc == null) { LOG.warn("Could not load tree: {}", localizedName.toString()); LOG.warn("Loading {} instead", getPathToXmlTree()); treeDoc = DOMUtil.createDocumentFromSystemID(getPathToXmlTree(), DOMParserOptions.getDefault().notNamespaceaware()); } return treeDoc; } }
public static WSSCapabilitiesDocument parse(InputStream in) { DOMParser domParser = DOMParser.createNew(DOMParserOptions.getDefault()); Document document = domParser.parse(new InputSource(in)); return new WSSCapabilitiesDocument(document); }
public static Document createEmptyDocument(final DOMParserOptions options) { DOMParserOptions opts = options != null ? options : DOMParserOptions.getDefault(); DocumentBuilderPool pool = getDocumentBuilderPool(); DocumentBuilder builder = pool.acquire(opts); try { return builder.newDocument(); } finally { pool.release(builder, opts); } }
/** * Initializes the backend from an external URL. Optional, an XSLT can be provided * * @param pMetadataURL external URL to resource * @param pXsltURL XSLT URL (optional). If present, MD document will be transformed. */ public synchronized void initBackend(URL pMetadataURL, URL pXsltURL) throws BackendManagerException { LOG.info("Initializing backend with external URL ..."); LOG.debug("URL: {}", pMetadataURL.toExternalForm()); LOG.debug("XSLT: {}", pXsltURL); Document lMd = DOMUtil.createDocumentFromURL(pMetadataURL, DOMParserOptions.getDefault().expandEntityReferences()); if (pXsltURL != null) { initBackend(lMd, pXsltURL.toExternalForm()); } else { initBackend(lMd); } }
private static Document parsePAOSResponse(InputStream instream) { return DOMParser.createNew(DOMParserOptions.getDefault().namespaceaware()).parse(new InputSource(instream)); }
/** * @param value */ public void setValue(Object value) { if (value instanceof MultipartFile) { MultipartFile multipartFile = (MultipartFile) value; try { Document documentFromStream = DOMUtil.createFromStream(multipartFile.getInputStream(), DOMParserOptions.getDefault().expandEntityReferences()); super.setValue(documentFromStream); } catch (IOException ex) { throw new IllegalArgumentException("Cannot read contents of multipart file", ex); } } else { super.setValue(value); } }
/** * Renders the bean as XML * * @param pBean bean to render * @return document with bean values * @throws ClassNotFoundException if bean class is not found * @throws IllegalAccessException if access to bean is not allowed * @throws InstantiationException if bean instantiation breaks up */ public Document toXML(BaseBean pBean) throws ClassNotFoundException, IllegalAccessException, InstantiationException { StringBuffer lBuffer = new StringBuffer(); if (pBean instanceof MultipleElementBean) { mXStream.processAnnotations(((MultipleElementBean) pBean).getBean().getClass()); lBuffer.append("<"); lBuffer.append(mMultiElementName); lBuffer.append(">"); List<BaseBean> lList = ((MultipleElementBean) pBean).getItems(); for (BaseBean aLList : lList) { lBuffer.append(transformSingleBean(aLList)); } lBuffer.append("</"); lBuffer.append(mMultiElementName); lBuffer.append(">"); } else { mXStream.processAnnotations(pBean.getClass()); lBuffer.append(transformSingleBean(pBean)); } return DOMUtil.createFromString(lBuffer.toString(), DOMParserOptions.getDefault().notNamespaceaware()); }
try { lXsltUrl = new URL(pXslt); xsltTransformer.setRuleset(DOMUtil.createDocumentFromURL(lXsltUrl, DOMParserOptions.getDefault().expandEntityReferences())); } catch (MalformedURLException e) { LOG.error("Could not read URL: {}", pXslt); Document lDoc = DOMUtil.createDocument(DOMParserOptions.getDefault().expandEntityReferences()); Source lSource = new DOMSource(pMetadata); Result lResult = new DOMResult(lDoc);
DOMParserOptions options = DOMParserOptions.getDefault(); options.setNamespaceaware(false); Document result = DOMParser.createNew(options).parse(new InputSource(isr));
/** * Creates a new DocumentBuilder with the given attributes. * <p/> * * @param parseroptions * options for the new parser. * @return DocumentBuilder. */ protected static DocumentBuilder createDocumentBuilder(final DOMParserOptions parseroptions) { DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); DOMParserOptions options = parseroptions; if (options == null) { options = DOMParserOptions.getDefault(); } fac.setValidating(options.isValidating()); fac.setNamespaceAware(options.isNamespaceaware()); fac.setIgnoringComments(options.isIgnoreComments()); fac.setIgnoringElementContentWhitespace(options.isIgnoreElementContentWhitespace()); fac.setXIncludeAware(options.isXincludeAware()); fac.setCoalescing(options.isCoalescing()); fac.setExpandEntityReferences(options.isExpandEntityReferences()); fac.setSchema(options.getSchema()); try { return fac.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } }
/** * Method creates session info from XML. * * @param sessionStream * the SessionStream (non namespace xml). * @return SessionInfo. */ public static SessionInfo createFromXML(final InputStream sessionStream) { try { Document doc = DOMParser.createNew(DOMParserOptions.getDefault()).parse( new InputSource(sessionStream)); SessionInfoVisitor sessionInfoVisitor = new SessionInfoVisitor(); new DocumentTraverser().traverseDepthFirst(doc, sessionInfoVisitor); return sessionInfoVisitor.getSessionInfo(); } catch (Exception e) { throw new SessionCreationException("Error while creating SessionInfo from XML: " + e, e); } }
public Document build() throws WebServiceDescriptionException { requestParameters = requestParameters == null ? new String[0] : requestParameters; HTTPRequest httpRequest = httpClientFactory.create(url).get(); HTTPResponse<InputStream> responseStream = httpRequest.parameter(requestParameters).asStream().start(); if (isInvalidResponse(responseStream)) { LOG.warn("Could not read capabilities from {}" + url); LOG.warn("Http response status code is {}", responseStream.getStatus().getCode()); throw new WebServiceDescriptionException("Could not read capabilities from " + url); } try { response = DOMUtil.createFromStream(responseStream.getContent(), DOMParserOptions.getDefault().expandEntityReferences()); } catch(Exception e) { throw new WebServiceDescriptionException("Could not parse capabilities document: " + e.getMessage()); }finally { requestParameters = null; // reset parameters } if (asIsoDocument) { return buildIsoDocument(); } return response; }
DOMParser domParser = DOMParser.createNew(DOMParserOptions.getDefault()); doc = domParser.parse(new InputSource(reqPayload.getAsStream())); wpsOperation = doc.getDocumentElement().getLocalName();
DOMParser domParser = DOMParser.createNew(DOMParserOptions.getDefault()); doc = domParser.parse(new InputSource(reqPayload.getAsStream())); sosOperation = doc.getDocumentElement().getLocalName();