public String getElementNamespaceUri(Object obj) { Element elem = (Element) obj; String uri = elem.getNamespaceURI(); if ( uri != null && uri.length() == 0 ) return null; else return uri; }
@Override String getNamespaceUri(Object node) { if (node instanceof Element) { return ((Element) node).getNamespaceURI(); } if (node instanceof Attribute) { return ((Attribute) node).getNamespaceURI(); } return null; }
public List operate(Object node, String localName, Namespace namespace) { if (node instanceof Element) { return((Element) node).getChildren(localName, namespace); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (root != null && root.getName().equals(localName) && root.getNamespaceURI().equals(namespace.getURI())) { return Collections.singletonList(root); } else return Collections.EMPTY_LIST; } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_namedChildren can not be applied on " + node.getClass()); */ } }
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.getChildren()); } else { result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
@Override String getNamespaceUri(Object node) { if (node instanceof Element) { return ((Element) node).getNamespaceURI(); } if (node instanceof Attribute) { return ((Attribute) node).getNamespaceURI(); } return null; }
String getNamespaceUri(Object node) { if(node instanceof Element) { return ((Element)node).getNamespaceURI(); } if(node instanceof Attribute) { return ((Attribute)node).getNamespaceURI(); } return null; }
@Override String getNamespaceUri(Object node) { if (node instanceof Element) { return ((Element) node).getNamespaceURI(); } if (node instanceof Attribute) { return ((Attribute) node).getNamespaceURI(); } return null; }
protected MessagePartInfo getFaultPart(OperationInfo operation, Element exDetail) { QName qname = new QName(exDetail.getNamespaceURI(), exDetail.getName()); for (Iterator itr = operation.getFaults().iterator(); itr.hasNext();) { FaultInfo faultInfo = (FaultInfo) itr.next(); MessagePartInfo part = faultInfo.getMessagePart(qname); if (part != null) return part; } return null; }
public QName getName() { Element el = getCurrentElement(); return new QName(el.getNamespaceURI(), el.getName(), el.getNamespacePrefix()); }
public QName getName() { Element el = getCurrentElement(); return new QName(el.getNamespaceURI(), el.getName(), el.getNamespacePrefix()); }
private void convertPages(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance("./x:element/x:structure/x:current[@level='bwmeta1.level.hierarchy_Journal_Article']/@position"); xpath.addNamespace("x", source.getNamespaceURI()); Attribute pages = (Attribute)xpath.selectSingleNode(source); if (pages != null) { String fp = pages.getValue().replaceFirst("-.*", ""); String lp = pages.getValue().replaceFirst(".*-", ""); metadata.setPages(fp, lp); } }
private void convertDoi(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance(".//x:idno[@type='DOI']"); xpath.addNamespace("x", source.getNamespaceURI()); Element doi = (Element)xpath.selectSingleNode(source); if (doi != null) { metadata.addId(IDType.DOI, XMLTools.getTextContent(doi)); } }
private void convertVolume(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Volume']/x:name[@type='canonical']"); xpath.addNamespace("x", source.getNamespaceURI()); Element volume = (Element)xpath.selectSingleNode(source); if (volume != null) { metadata.setVolume(XMLTools.getTextContent(volume)); } }
private void convertYear(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Year']/x:name[@type='canonical']"); xpath.addNamespace("x", source.getNamespaceURI()); Element year = (Element)xpath.selectSingleNode(source); if (year != null) { metadata.setDate(DateType.PUBLISHED, null, null, XMLTools.getTextContent(year)); } }
private void convertAbstract(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance(".//x:abstract"); xpath.addNamespace("x", source.getNamespaceURI()); Element abstrakt = (Element)xpath.selectSingleNode(source); if (abstrakt != null) { metadata.setAbstrakt(XMLTools.getTextContent(abstrakt)); } }
private void convertTitle(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance("./x:element/x:name[not(@type)]"); xpath.addNamespace("x", source.getNamespaceURI()); Element title = (Element)xpath.selectSingleNode(source); if (title != null) { metadata.setTitle(XMLTools.getTextContent(title)); } }
private void convertVolume(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance(".//x:monogr/x:imprint/x:biblScope[@unit='volume']"); xpath.addNamespace("x", source.getNamespaceURI()); Element volume = (Element)xpath.selectSingleNode(source); if (volume != null) { metadata.setVolume(XMLTools.getTextContent(volume)); } }
private void convertIssue(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance(".//x:monogr/x:imprint/x:biblScope[@unit='issue']"); xpath.addNamespace("x", source.getNamespaceURI()); Element issue = (Element)xpath.selectSingleNode(source); if (issue != null) { metadata.setIssue(XMLTools.getTextContent(issue)); } }
private void convertTitle(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance(".//x:titleStmt/x:title"); xpath.addNamespace("x", source.getNamespaceURI()); Element title = (Element)xpath.selectSingleNode(source); if (title != null) { metadata.setTitle(XMLTools.getTextContent(title)); } }
private void convertJournal(Element source, DocumentMetadata metadata) throws JDOMException { XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Journal']/x:name[@type='canonical']"); xpath.addNamespace("x", source.getNamespaceURI()); Element journal = (Element)xpath.selectSingleNode(source); if (journal != null) { metadata.setJournal(XMLTools.getTextContent(journal)); } }