About oXygen XML Editor |
Controlled Attribute Values (Part 2 - Advanced) Posted: 17 Jul 2015 03:42 AM PDT As already presented in Controlled Attribute Values for your DITA Project, Oxygen allows you to add or replace possible values for attributes or elements based on a simple configuration file. A more complex scenario is one in which in order to decide which values to provide, you need more context information. Let's take this DITA fragment: <metadata> What we want is to offer proposals for @content but the possible values for @content depend on the value of @name. We will see how we can solve this dependency. The configuration fileThe configuration file (cc_value_config.xml) allows calling an XSLT stylesheet and that's just what we will do: <match elementName="othermeta" attributeName="content"> As you can see, we can't express the dependency between @content and @name inside the configuration file . I also want to mention that because the values for @content are dynamic, we want the XSLT script to execute every time the values are requested (we shouldn't cache the results). We enforce this by setting @useCache to false. The XSLT scriptThe XSLT script has access to the XML document (through the documentSystemID parameter) but it lacks any context information, we can't really tell for which othermeta element was the script invoked. To counter this limitation, we will use Java extension functions and we will call Oxygen's Java-based API from the XSLT. Here how it looks: <?xml version="1.0" encoding="UTF-8"?> It is also worth mentioning that in the next Oxygen version (17.1) we will provide a more elegant solution to this situation. The XSLT script will receive a new parameter, an XPath expression that will identify the element for which content completion was invoked. But maybe we will talk about that in a future post... |
You are subscribed to email updates from About oXygen XML Editor
To stop receiving these emails, you may unsubscribe now. |
Email delivery powered by Google |
Google Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |