use of org.jdom2.xpath.XPath in project mycore by MyCoRe-Org.
the class MCRAndOthersTransformer method buildField.
void buildField(BibtexPerson person, Element parent) {
Element modsName = buildElement(xPath, null, parent);
buildElement("mods:etAl", null, modsName);
}
use of org.jdom2.xpath.XPath in project mycore by MyCoRe-Org.
the class MCRPagesTransformer method buildField.
void buildField(BibtexAbstractValue value, Element parent) {
String pages = ((BibtexString) value).getContent();
pages = normalizeValue(pages);
Element part = buildElement(xPath, null, parent);
part.addContent(MCRMODSPagesHelper.buildExtentPages(pages));
}
use of org.jdom2.xpath.XPath in project mycore by MyCoRe-Org.
the class MCRURNObjectXPathMetadataManager method removeIdentifier.
@Override
public void removeIdentifier(MCRDNBURN identifier, MCRBase obj, String additional) {
String xpath = getProperties().get("Xpath");
Document xml = obj.createXML();
XPathFactory xPathFactory = XPathFactory.instance();
XPathExpression<Element> xp = xPathFactory.compile(xpath, Filters.element());
List<Element> elements = xp.evaluate(xml);
elements.stream().filter(element -> element.getTextTrim().equals(identifier.asString())).forEach(Element::detach);
}
use of org.jdom2.xpath.XPath in project mycore by MyCoRe-Org.
the class MCRAclEditorResource method transform.
protected InputStream transform(String xmlFile) throws Exception {
InputStream guiXML = getClass().getResourceAsStream(xmlFile);
if (guiXML == null) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).build());
}
SAXBuilder saxBuilder = new SAXBuilder();
Document webPage = saxBuilder.build(guiXML);
XPathExpression<Object> xpath = XPathFactory.instance().compile("/MyCoReWebPage/section/div[@id='mycore-acl-editor2']");
Object node = xpath.evaluateFirst(webPage);
MCRSession mcrSession = MCRSessionMgr.getCurrentSession();
String lang = mcrSession.getCurrentLanguage();
if (node != null) {
Element mainDiv = (Element) node;
mainDiv.setAttribute("lang", lang);
String bsPath = CONFIG.getString("MCR.bootstrap.path", "");
if (!bsPath.equals("")) {
bsPath = MCRFrontendUtil.getBaseURL() + bsPath;
Element item = new Element("link").setAttribute("href", bsPath).setAttribute("rel", "stylesheet").setAttribute("type", "text/css");
mainDiv.addContent(0, item);
}
}
MCRContent content = MCRJerseyUtil.transform(webPage, request);
return content.getInputStream();
}
use of org.jdom2.xpath.XPath in project mycore by MyCoRe-Org.
the class MCRLayoutUtilities method getItem.
/**
* Returns a Element presentation of an item[@href=$webpageID]
*
* @param webpageID
* @return Element
*/
private static Element getItem(String webpageID) {
Element item = itemStore.get(webpageID);
if (item == null) {
XPathExpression<Element> xpath = XPATH_FACTORY.compile("//.[@href='" + webpageID + "']", Filters.element());
item = xpath.evaluateFirst(getNavi());
itemStore.put(webpageID, item);
}
return item;
}
Aggregations