24.08.2015 Views

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}if (node.getType() == <strong>Author</strong>Node.NODE_TYPE_ELEMENT) {<strong>Author</strong>Element element = (<strong>Author</strong>Element) node;if ("ref".equals(element.getLocalName())) {AttrValue attrValue = element.getAttribute("location");if (attrValue != null) {displayName = attrValue.getValue();}}}return displayName;<strong>Author</strong> Developer Guide | 2184. The method resolveReference resolves the reference of the node and returns a SAXSource with the parserand the parser's input source. It takes as arguments an <strong>Author</strong>Node that represents the node for which the referenceneeds resolving, the systemID of the node, the <strong>Author</strong>Access with access methods to the <strong>Author</strong> data model anda SAX EntityResolver which resolves resources that are already opened in another editor or resolve resourcesthrough the <strong>XML</strong> catalog. In the implementation you need to resolve the reference relative to the systemID, andcreate a parser and an input source over the resolved reference.public SAXSource resolveReference(<strong>Author</strong>Node node,String systemID,<strong>Author</strong>Access authorAccess,EntityResolver entityResolver) {SAXSource saxSource = null;if (node.getType() == <strong>Author</strong>Node.NODE_TYPE_ELEMENT) {<strong>Author</strong>Element element = (<strong>Author</strong>Element) node;if ("ref".equals(element.getLocalName())) {AttrValue attrValue = element.getAttribute("location");if (attrValue != null) {String attrStringVal = attrValue.getValue();try {URL absoluteUrl = new URL(new URL(systemID),authorAccess.correctURL(attrStringVal));InputSource inputSource = entityResolver.resolveEntity(null,absoluteUrl.toString());if(inputSource == null) {inputSource = new InputSource(absoluteUrl.toString());}<strong>XML</strong>Reader xmlReader = authorAccess.newNonValidating<strong>XML</strong>Reader();xmlReader.setEntityResolver(entityResolver);}}}saxSource = new SAXSource(xmlReader, inputSource);} catch (MalformedURLException e) {logger.error(e, e);} catch (SAXException e) {logger.error(e, e);} catch (IOException e) {logger.error(e, e);}}return saxSource;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!