Hello,
Oxygen has support for configuring the content completion through a
configuration file [1]. In such a configuration file you can specify a
XSLT that will be used to extract the possible values:
<?xml-model
href="http://www.oxygenxml.com/ns/ccfilter/config/ccConfigSchemaFilter.sch"
type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.oxygenxml.com/ns/ccfilter/config
http://www.oxygenxml.com/ns/ccfilter/config/ccConfigSchemaFilter.xsd"
xmlns="http://www.oxygenxml.com/ns/ccfilter/config">
<!-- The contributed values are obtained by executing the given
XSLT -->
<match elementName="*elementX*"
elementNS="http://www.tei-c.org/ns/1.0" attributeName="*attributeY*">
<xslt href="../xsl/extractIDs.xsl" useCache="false"
action="replace"/>
</match>
</config>
The invokedextractIDs.xsl can read those values from an external file (
doc('taxonomy.xml')//category[@xml:id='occupations']) or even from the
current document (if needed) by using the parameters *documentSystemID
*and **contextElementXPathExpression**
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:saxon="http://saxon.sf.net/"
exclude-result-prefixes="xs"
version="2.0">
<xsl:param name="*documentSystemID*" as="xs:string"></xsl:param>
<xsl:param name="*contextElementXPathExpression*"
as="xs:string"></xsl:param>
<xsl:template name="start">
<xsl:apply-templates select="*doc($documentSystemID)*"/>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="propertyElement"
select="saxon:eval(saxon:expression($contextElementXPathExpression, ./*))"/>
*<items>**
** <xsl:if test="$propertyElement/@name = 'color'">**
** <item value='red'/>**
** <item value='blue'/> **
** </xsl:if>**
** <xsl:if test="$propertyElement/@name = 'shape'">**
** <item value='rectangle'/>**
** <item value='square'/> **
** </xsl:if>**
** </items>*
</xsl:template>
</xsl:stylesheet>
I also presented this idea a few years ago at XML Prague but at that
time it was an Oxygen extension. Some time after that we bundled this
functionality into Oxygen. As a matter of fact, I used some TEI examples
when I presented the concept at XML Prague. [2]
[1]
https://www.oxygenxml.com/doc/versions/20.1/ug-editor/topics/configuring-content-completion-proposals.html#configuring-content-completion-proposals
[2]
https://youtu.be/76I-l8Y21nc?list=PLslaBBfd4kppQ6Z-d5YUYoJydM6L78JZ1&t=356
Best regards,
Alex
--
Alex Jitianu
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On 10/28/2018 9:35 PM, James Cummings wrote:
Hi there,
In TEI, as many of you know, we write our schemas in the TEI ODD
customisation language and generate schemas in formats such as like
Relax NG, etc. but my question, I think, is really about the way
oXygen interprets Relax NG in providing its helpful dropdown menus, etc.
In oXygen when we have an attribute value that has a data type of
anyURI oXygen helpfully pops up a list of potential values based on
listing all the @xml:id's in the document. The problem, as I'm sure
many have encountered, is that lists all the @xml:id's not those that
might make suitable values for this attribute. Is there a way in the
generated Relax NG to somehow specify that the values are any of the
descendant @xml:id's from a particular XPath within the document (or
indeed another document)?
For a use-case what I'm interested in doing in TEI is, for a
particular element customise the allowed values of the @ana attribute
(which takes multiple whitespace-separated anyURI datatype values). We
often use this attribute in TEI to point to a number of other elements
including a taxonomy of arbitrarily-deeply nested categories in the
document instance (or shared commonly between a number of document
instances.) For example:
===
<taxonomy>
<category xml:id="MSmaterials">
<catDesc>A list of Manuscript Materials</catDesc>
<category xml:id="paper">
<catDesc>Paper</catDesc>
</category>
<category xml:id="parchment">
<catDesc>Parchment</catDesc>
</category>
</category>
<category xml:id="occupations">
<catDesc>A list of occupations</catDesc>
<category xml:id="tinker">
<catDesc>A tinker</catDesc>
</category>
<category xml:id="tailor">
<catDesc>A tailor</catDesc>
</category>
<category xml:id="soldier">
<catDesc>A soldier</catDesc>
</category>
<category xml:id="spy">
<catDesc>A spy</catDesc>
</category>
</category>
</taxonomy>
===
Here we have two categories (MSmaterials and occupations) with a
variety of sub-categories, but that could go many levels down. When
adding the @ana attribute in oXygen the drop down would give us all of
these @xml:ids and all those elsewhere in the document.
Is there a way manually, or semi-automatically, in the Relax NG to
signal to oXygen that for elementX/@attributeY the drop-down menu in
the XML Editor should only provide @xml:ids from within descendants a
particular element (e.g. //category[@xml:id='occupations'])
In the TEI ODD customisation file, I could, of course, limit it to
specific values.... and generate Relax NG from that. We'd do that with
something like the following (embedded in an elementSpec:
===
<attDef ident="ana" mode="change">
<valList mode="add" type="closed">
<valItem ident="#tinker">
<desc>A tinker</desc>
</valItem>
<valItem ident="#tailor">
<desc>A tailor</desc>
</valItem>
<valItem ident="#soldier">
<desc>A soldier</desc>
</valItem>
<valItem ident="#spy">
<desc>A spy</desc>
</valItem>
</valList>
</attDef>
===
Which when transformed to a closed value list in Relax NG would mean
that I could choose '#tinker', '#tailor', '#soldier', '#spy' - giving
hard-coded strings that then function as URI fragments. But of course
neglects that the attribute can take multiple values in any order.
Someone can reasonably be both a spy and soldier.
I suppose I could on regenerating the schema, have the processing look
up this <taxonomy> and pull out all the values, and automatically
hard-code them in all possible particular orders, but that, I hope you
agree, seems silly and of course doesn't scale. Also it has the
problem of needing to regenerate the schema every time a new category
is added. I could do this with Schematron, I suppose, i.e. stick in a
Schematron rule that says for elementX/attributeY look up the values
in doc('taxonomy.xml')//category[@xml:id='occuptaions'], or something.
But while that might help with validation, I don't believe oXygen will
pick that up for the dropdown menu.
I have a very vague memory of someone looking working on an extension
to oXygen which did something like this (though I think externally
from the schema). If someone remembers the project I'm forgetting,
please do let me know. If there was a way to signal to oXygen from
Relax NG the XPath which to use to produce the dropdown list, then I
can see us adding something that would produce that signal to TEI ODD
processing, and lots of projects using it. Is this something that is
already available, feasible, or completely ridiculous?
Thanks for any thoughts.
James Cummings
_______________________________________________
oXygen-user mailing list
[email protected]
https://www.oxygenxml.com/mailman/listinfo/oxygen-user
_______________________________________________
oXygen-user mailing list
[email protected]
https://www.oxygenxml.com/mailman/listinfo/oxygen-user