Custom variable defined by XPath in Document Type Association

Are you missing a feature? Request its implementation here.
erik.holley
Posts: 5
Joined: Sat Jan 21, 2012 11:29 am

Custom variable defined by XPath in Document Type Association

Post by erik.holley »

I have frameworks which require custom variables throughout the authoring environment. There is currently no cohesive way to access a single set of key/value pairs in every type of language we work in: CSS, XSLT, XPath, Relax, etc.

In my particular case, the users are allowed to specify the server URL where assets are pulled from. This is done in a special configuration.xml file. Thus, in subsequent XML files, only the asset filename needs to be referenced. The folder structure is such that in XSLT I can make my way back up the hierarchy, find the configuration file, query for the proper server URL based on a prefix, concat the URL with the asset filename, and finally have the absolute URL.

Great acrobatics are needed to determine and validate if an asset exists by using Schematron due to the language constraints. If I wanted to display the asset image in the author editor window, the CSS would need to know how to jump through all of those hoops to get the absolute URL. (This is possible with an frightening oxy_xpath repeated x-number of times. I have assets spread throughout my stylesheet.)

What I'd like is a panel for variables that are tied to the framework through Document Type Association. Perhaps the variable could be evaluated as a constant string, an XPath expression, or a special namespace XSLT function. Thus, I can take great pains in defining an expression or function which takes into account the current URL, performs operations, and returns a result--but only do it in one place--not spread throughout CSS, XSLT, Schematron, etc.

I'd like to then reference that variable/function in a fairly uniform way, language permitting.
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Custom variable defined by XPath in Document Type Association

Post by Radu »

Hi Eric,

So you need to properly render the XML (using CSS) in the Author mode, validate it (using Schematron) and process it using XSLT.
So an asset is basically a resource which can be referenced in the XML file? And sometimes it is an image?

Could XML Catalogs be an answer to this?

For example all your XML files would have an xml:base attribute on the root element like:

Code: Select all

<rootElement xml:base="http://www.alias.com">....
Then you would create an XML Catalog file which maps the logical base to a real location like:

Code: Select all

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem systemIdStartString="http://www.alias.com" rewritePrefix="http://www.my-real-server.com"/>
<rewriteURI uriStartString="http://www.alias.com" rewritePrefix="http://www.my-real-server.com"/>
</catalog>
and add this XML catalog file in the Preferences->"XML / XML Catalog" page.

When relative image references are resolved in the Oxygen Author mode they will be resolved relative to the xml:base which will first be passed through the catalog.
Also the Schematron/XSLTs should see the xml:base as the location relative to which the references should be resolved.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply