DITALinkTextResolver.resolveReference sample
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 9
- Joined: Tue Mar 26, 2013 12:00 am
- Location: Paris, France
- Contact:
DITALinkTextResolver.resolveReference sample
Hi,
I try to extend the DITALinkTextResolver.resolveReference and instead of reinvent everything, I would be interesting to get either the standard oXygen DITA implementation or any other implementation made by this forum user.
My implementation needs to concatenate some prolog metadata (if there are some) to the topic title.
Thanks for sharing, Pierre
I try to extend the DITALinkTextResolver.resolveReference and instead of reinvent everything, I would be interesting to get either the standard oXygen DITA implementation or any other implementation made by this forum user.
My implementation needs to concatenate some prolog metadata (if there are some) to the topic title.
Thanks for sharing, Pierre
-
- Posts: 1017
- Joined: Wed Nov 16, 2005 11:11 am
Re: DITALinkTextResolver.resolveReference sample
Post by alex_jitianu »
Hello,
The code for DITALinkTextResolver is open source and it's available in the oxygen-sample-framework module from our SDK sample project. After you set up the project, you need to run mvn generate-resources (the sample project is a Maven multi-module project) inside the oxygen-sample-framework module. This will create a directory oxygen-sample-framework/samples in which you can find all framework specific Java extensions. For convenience, I will also send you the source code directly on your email address.
Best regards,
Alex
The code for DITALinkTextResolver is open source and it's available in the oxygen-sample-framework module from our SDK sample project. After you set up the project, you need to run mvn generate-resources (the sample project is a Maven multi-module project) inside the oxygen-sample-framework module. This will create a directory oxygen-sample-framework/samples in which you can find all framework specific Java extensions. For convenience, I will also send you the source code directly on your email address.
Best regards,
Alex
-
- Posts: 9
- Joined: Tue Mar 26, 2013 12:00 am
- Location: Paris, France
- Contact:
Re: DITALinkTextResolver.resolveReference sample
Thanks a lot for your answer.alex_jitianu wrote: This will create a directory oxygen-sample-framework/samples in which you can find all framework specific Java extensions.
I've got the framework downloaded but it seems that the
Code: Select all
ro.sync.ecss.dita.DITAAccess
Looking at the code, it is exactely the
Code: Select all
DITAAccess.computeLinkText
So is this an other project to download ? How to get that part of the framework ?
Pierre
-
- Posts: 1017
- Joined: Wed Nov 16, 2005 11:11 am
Re: DITALinkTextResolver.resolveReference sample
Post by alex_jitianu »
Hello,
Unfortunately DITAAccess code is not API but more of a gateway between API and private code. I will file in a request to enhance our API to allow you to extract additional content from the target of the link. Meanwhile, you probably have to identify the case where the link is a topic (from the ID structure) and extract the metadata yourself. For that you could:
- parse the document using the DOM model and search through it, or
- using our API you can create an XSLT or XQuery transformer and execute a query that will extract that metadata from the target document:
Personally, I would go with the second solution...
Best regards,
Alex
Unfortunately DITAAccess code is not API but more of a gateway between API and private code. I will file in a request to enhance our API to allow you to extract additional content from the target of the link. Meanwhile, you probably have to identify the case where the link is a topic (from the ID structure) and extract the metadata yourself. For that you could:
- parse the document using the DOM model and search through it, or
- using our API you can create an XSLT or XQuery transformer and execute a query that will extract that metadata from the target document:
Code: Select all
public class DitaLinkTextResolver extends LinkTextResolver {
/**
* Caching this object will ensure a much faster DITA topic parsing.
*/
Object grammarToken = null;
/**
* @throws TransformerException
*/
private String getMetaData(URL target) throws TransformerException {
XMLUtilAccess xmlUtilAccess = PluginWorkspaceProvider.getPluginWorkspace().getXMLUtilAccess();
Source xsltSource = new StreamSource(new StringReader(
// TODO Build a proper XSLT based on the link href. You could also build
// an XSLT in which the variables parts (like the topic ID perhaps) are
// expressed as parameters.
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n" +
" exclude-result-prefixes=\"xs\"\n" +
" version=\"2.0\">\n" +
" <xsl:template match=\"/topic/prolog\"></xsl:template>\n" +
"</xsl:stylesheet>"));
// xmlUtilAccess.createXQueryTransformer(xquerySource, null, XMLUtilAccess.TRANSFORMER_SAXON_ENTERPRISE_EDITION);
Transformer transfomer = xmlUtilAccess.createXSLTTransformer(xsltSource, null, XMLUtilAccess.TRANSFORMER_SAXON_ENTERPRISE_EDITION);
XMLReaderWithGrammar readerAndCache = xmlUtilAccess.newNonValidatingXMLReader(grammarToken);
XMLReader reader = readerAndCache.getXmlReader();
// Caching this object will ensure a much faster DITA topic parsing.
grammarToken = readerAndCache.getGrammarCache();
SAXSource xmlSource = new SAXSource(reader, new InputSource(target.toExternalForm()));
StringWriter writer = new StringWriter();
transfomer.transform(xmlSource, new StreamResult(writer));
return writer.toString();
}
Best regards,
Alex
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service