Print

Print


Hi,

On 24/06/2015 22:39, Martin Holmes wrote:
>
> I have a feeling this might now be possible in Oxygen -- check with 
> their support -- but up to now, we've been doing this in a sort of 
> roundabout way: I have ant build files which rebuild our ODD file 
> using all the values of personography @xml:ids as a valList for the 
> attribute concerned, and then build the schema for it. Then Oxygen 
> does prompt for the correct values. It's slightly annoying because it 
> means you have to run that job every time you modify the personography 
> before you can use a new id in the pointer attribute, but it does work.
>

I think I have found a slightly more flexible approach using Schematron 
Quick Fixes (https://github.com/schematron-quickfix/), which are 
supported since Oxygen 17 (see 
http://www.oxygenxml.com/demo/Schematron_Quick_Fixes.html).

For example, this rudimentary Schematron file could do the job (untested!):

<schema
   xmlns="http://purl.oclc.org/dsdl/schematron"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:tei="http://www.tei-c.org/ns/1.0"
   xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
   queryBinding="xslt2">
     <ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
     
   <xsl:variable name="person.index" select="doc('person-index.xml')//tei:person"/>
   
   <pattern>
     <rule context="tei:name">
       <report role="warning" test="not(@ref)" sqf:fix="add.ref">
         A name should have a @ref attribute pointing to a person definition.
       </report>
       <let name="person.id" value="$person.index[matches(tei:persName, normalize-space(current()))]/@xml:id"/>
       <sqf:fix id="add.ref">
         <sqf:description>
           <sqf:title>
             Add a @ref pointing to a person definition.
           </sqf:title>
         </sqf:description>
         <sqf:add match="." node-type="attribute" target="ref" select="concat('#', $person.id)"/>
       </sqf:fix>
     </rule>
   </pattern>

</schema>

The $person.index variable loads all person definitions from an index 
file; the Schematron rule matching <tei:name> elements will try to look 
up a person definition in $person.index matching the current name. Next, 
the SQF will propose to add a @ref attribute to the <tei:name> pointing 
to the the @xml:id value of the matching <tei:person> element in 
$person.index.

Though this example is very rudimentary, you could add some degree of 
'dynamism' to offer multiple suggestions, should multiple possible 
person definitions be found (see the discussion at 
https://github.com/schematron-quickfix/sqf/issues/3).

While I think this is slightly more flexible than Martin's approach in 
that the ODD file doesn't have to be regenerated over again, the 
definition of $person.index in my example still requires a precompiled 
index file containing all unique names found in a TEI document or 
collection. While it is theoretically possible to do a live search over 
a collection (by swapping the doc() function with a collection() call 
over the entire collection), this would probably hardly be workable 
since each new Schematron validation run (basically after each keystroke 
in an XML document being validated against this Schematron in Oxygen) 
will have to scan the collection again for each name in that document. 
But perhaps Oxygen allows for database integration with e.g. an eXist-db 
instance that could boost performance of the $person.index lookup; I 
don't know if that's possible (if it is possible, I'd be interested to 
learn more).

Best,

Ron