public static void deepCopyDocument(Document ttml, File target) throws IOException { try { XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile("//*/@backgroundImage"); NodeList nl = (NodeList) expr.evaluate(ttml, XPathConstants.NODESET); for (int i = 0; i < nl.getLength(); i++) { Node backgroundImage = nl.item(i); URI backgroundImageUri = URI.create(backgroundImage.getNodeValue()); if (!backgroundImageUri.isAbsolute()) { copyLarge(new URI(ttml.getDocumentURI()).resolve(backgroundImageUri).toURL().openStream(), new File(target.toURI().resolve(backgroundImageUri).toURL().getFile())); } } copyLarge(new URI(ttml.getDocumentURI()).toURL().openStream(), target); } catch (XPathExpressionException e) { throw new IOException(e); } catch (URISyntaxException e) { throw new IOException(e); } }
protected static List<byte[]> extractImages(Document ttml) throws XPathExpressionException, URISyntaxException, IOException { XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile("//*/@backgroundImage"); NodeList nl = (NodeList) expr.evaluate(ttml, XPathConstants.NODESET); LinkedHashMap<String, String> internalNames2Original = new LinkedHashMap<String, String>(); int p = 1; for (int i = 0; i < nl.getLength(); i++) { Node bgImageNode = nl.item(i); String uri = bgImageNode.getNodeValue(); String ext = uri.substring(uri.lastIndexOf(".")); String internalName = internalNames2Original.get(uri); if (internalName == null) { internalName = "urn:mp4parser:" + p++ + ext; internalNames2Original.put(internalName, uri); } bgImageNode.setNodeValue(internalName); } List<byte[]> images = new ArrayList<byte[]>(); if (!internalNames2Original.isEmpty()) { for (Map.Entry<String, String> internalName2Original : internalNames2Original.entrySet()) { URI pic = new URI(ttml.getDocumentURI()).resolve(internalName2Original.getValue()); images.add(streamToByteArray(pic.toURL().openStream())); } } return images; }
public final String getBaseURI() { switch (getNodeType()) { case DOCUMENT_NODE: return sanitizeUri(((Document) this).getDocumentURI());
public String getSystemId() { try { return sysId == null ? document.getDocumentURI() : sysId; } catch (Throwable ex) { //ignore, probably not DOM level 3 } return sysId; } /**
public String getSystemId() { try { return sysId == null ? document.getDocumentURI() : sysId; } catch (Throwable ex) { //ignore, probably not DOM level 3 } return sysId; } /**
public String getSystemId() { try { return sysId == null ? document.getDocumentURI() : sysId; } catch (Throwable ex) { //ignore, probably not DOM level 3 } return sysId; } /**
public String getSystemId() { try { return sysId == null ? document.getDocumentURI() : sysId; } catch (Throwable ex) { //ignore, probably not DOM level 3 } return sysId; } /**
private static int compareDocuments(Document docA, Document docB) { // Arbitrary but fulfills the spec (provided documenURI is always set) if (docB.getDocumentURI() == null && docA.getDocumentURI() == null) { return System.identityHashCode(docA) - System.identityHashCode(docB); } return docB.getDocumentURI().compareTo(docA.getDocumentURI()); }
private String buildMessage(String cause, Node source) { return MessageFormat.format("\n Source Document: {0}\n Cause: {1}", source.getOwnerDocument().getDocumentURI(), cause); }
/** * Returns the URL of this location as a String. */ public String toString() { return bridgeContext.getDocument() .getDocumentURI(); } }
/** * @return * @see org.w3c.dom.Document#getDocumentURI() */ public String getDocumentURI() { return getParent().getDocumentURI(); }
private void processSource(Element documentElement, Node source, TagLibraryImpl taglibrary, String name) { String docURI = documentElement.getOwnerDocument().getDocumentURI(); String s = getNodeText(source); try { URL url = new URL(new URL(docURI), s); taglibrary.putUserTag(name, url); } catch (MalformedURLException e) { throw new FacesException(e); } }
private void processSource(Element documentElement, Node source, TagLibraryImpl taglibrary, String name) { String docURI = documentElement.getOwnerDocument().getDocumentURI(); String s = getNodeText(source); try { URL url = new URL(new URL(docURI), s); taglibrary.putUserTag(name, url); } catch (MalformedURLException e) { throw new FacesException(e); } }
private String doc2SystemId(Element ele) { String documentURI = null; final Document ownerDoc = ele.getOwnerDocument(); if (ownerDoc instanceof org.apache.xerces.impl.xs.opti.SchemaDOM) { documentURI = ((org.apache.xerces.impl.xs.opti.SchemaDOM) ownerDoc).getDocumentURI(); } else if (ownerDoc.getImplementation().hasFeature("Core", "3.0")) { documentURI = ownerDoc.getDocumentURI(); } return documentURI != null ? documentURI : (String) fDoc2SystemId.get(ele); }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; String docURI; doc = (Document) load("hc_staff", false); docURI = doc.getDocumentURI(); assertNotNull("documentgetdocumenturi01", docURI); } /**
public QOSDimension readQOSDimension(final Document document) throws WSQMLException { QOSDimension desc = null; try { desc = this.readQOSDimension(new URI(document.getDocumentURI()), SourceHelper.convertDOMSource2InputSource(new DOMSource(document))); } catch (final URISyntaxException e) { throw new WSQMLException(e); } catch (final XmlException e) { throw new WSQMLException(e); } return desc; }
public Constraint readConstraint(final Document document) throws WSQMLException { Constraint desc = null; try { desc = this.readConstraint(new URI(document.getDocumentURI()), SourceHelper.convertDOMSource2InputSource(new DOMSource(document))); } catch (final URISyntaxException e) { throw new WSQMLException(e); } catch (final XmlException e) { throw new WSQMLException(e); } return desc; }
/** * The user agent reloads the current document. */ public void reload() { String url = bridgeContext.getDocument() .getDocumentURI(); bridgeContext.getUserAgent().loadDocument(url); }
@Override public String getCurrentUrl() { if (webView.getEngine().getDocument() == null) { return ""; } return webView.getEngine().getDocument().getDocumentURI(); } }
private void parseWsdl(Document document) throws WSSPolicyException { try { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader reader = wsdlFactory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); wsdlDefinition = reader.readWSDL(document.getDocumentURI(), document); operationPolicies = findPoliciesByOperation(wsdlDefinition); } catch (WSDLException e) { throw new WSSPolicyException(e.getMessage(), e); } }