[Schematron] selecting mode for generating id's
Lars Huttar
lars_huttar at sil.org
Wed Sep 24 17:21:44 EDT 2008
Thanks, that helps.
I guess my next hurdle is that I'm using schematron-report.xsl instead
of iso_svrl.xsl, so I'm not sure how to apply what you've written below
to our situation. I believe the reason I chose to use
schematron-report.xsl was that it outputs HTML, whereas iso_svrl.xsl
obviously outputs SVRL. And I'm not aware of any other recommended
SVRL-to-HTML stylesheet out there.
I commented on this here [1] (with PS here [2]).
[1]
http://www.oreillynet.com/xml/blog/2007/03/what_else_should_schematron_ha.html#comment-953077
[2]
http://www.oreillynet.com/xml/blog/2007/03/what_else_should_schematron_ha.html#comment-953146
It just seems like a gaping hole not to have a suggested
SVRL-to-human-readable-report stylesheet that works with the current
recommended versions of Schematron. But maybe I'm missing something.
I guess I could use iso_svrl.xsl, and then tack on my own svrl-to-html
stylesheet based on David Carlisle's schematron-report.xsl. But I was
hoping there was a solution that worked out of the box, so that I could
expect it to keep working as versions of Schematron are upgraded.
Lars
On 9/20/2008 5:18 AM, Rick Jelliffe wrote:
> There are two issues here.
>
> 1) The Schematron skeleton provides various utility templates
> available for meta-stylesheets to generate paths and ids. There are
> three different ones for paths, and two for repeatable ids,
> contributed by users on this list.
>
> 2) SVRL has an @location attribute which provides one of these paths.
> In iso_svrl.xsl as distributed is hard-coded to the ugly path suited
> for computers.
>
> So, iso_svrl.xsl does not use the repeatable-ID making facility but
> the path facility. You may be able to extend iso_svrl.xsl to use it.
>
> In the most recent skeleton I have been working on I have added a
> selection function and a command-line parameter to select the path
> notation:
>
> <xsl:template name="generate-default-rules">
> <xsl:text> </xsl:text>
> <xsl:comment>MODE:
> SCHEMATRON-SELECT-FULL-PATH</xsl:comment><xsl:text> </xsl:text>
> <xsl:comment>This mode can be used to generate an ugly though
> full XPath for locators</xsl:comment><xsl:text> </xsl:text>
> <axsl:template match="*" mode="schematron-select-full-path">
> <axsl:choose>
> <axsl:when test=" $full-path-notation = '1' ">
> <!-- Use for computers, but rather unreadable
> for humans -->
> <axsl:apply-templates select="."
> mode="schematron-get-full-path"/>
> </axsl:when>
> <axsl:when test=" $full-path-notation = '2' ">
> <!-- Use for humans, but no good for paths
> unless namespaces are known out-of-band -->
> <axsl:apply-templates select="."
> mode="schematron-get-full-path-2"/>
> </axsl:when>
> <axsl:when test=" $full-path-notation = '3' ">
> <!-- Obsolescent. Use for humans, but no good
> for paths unless namespaces are known out-of-band -->
> <axsl:apply-templates select="."
> mode="schematron-get-full-path-3"/>
> </axsl:when>
>
> <axsl:otherwise >
> <!-- Use for computers, but rather unreadable
> for humans -->
> <axsl:apply-templates select="."
> mode="schematron-get-full-path"/>
> </axsl:otherwise>
> </axsl:choose>
> </axsl:template>
>
> and I will alter the SVRL code to call schematron-select-full-path and
> the command parameter.
>
> Which brings us to the question, would it be useful if
> 1) the @location parameter could also generate IDs or
> 2) are the @location XPath and the IDs potentially needed at the same
> time, so some other attribute should be available, and
> 3) is this something that the ISO standard should have, or is it OK
> just to be a foreign attribute specific to iso_svrl.xsl ?
>
> Cheers
> Rick
>
>
>
> Lars Huttar wrote:
>> I think the request below got buried under other discussions...
>> Does anybody have suggestions regarding how to select the alternative
>> id-generating templates?
>>
>> Lars
>>
>>
>> On 9/15/2008 4:00 PM, Lars Huttar wrote:
>>
>>> *Eric van der Vlist* vdv at dyomedea.com
>>>
>>> <mailto:schematron-love-in%40eccnet.eccnet.com?Subject=%5BSchematron-love-in%5D%20HTML%20report&In-Reply-To=103dd5200705290945p549d4c78l830c8dab8af41fa8%40mail.gmail.com>
>>> /wrote on Wed May 30 02:36:27 EDT 2007:/
>>>
>>>> Le mardi 29 mai 2007 à 17:45 +0100, David Carlisle a écrit :
>>>>
>>>>> / On 29/05/07, Eric van der Vlist <vdv at dyomedea.com
>>>>> <http://eccnet.eccnet.com/mailman/listinfo/schematron-love-in>>
>>>>> wrote:
>>>>>
>>>> />/ > Hi,
>>>> />/ >
>>>> />/ > Just wondering if anyone has already started to write ISO
>>>> (X)HTML
>>>> />/ > Schematron report generators and what people would think
>>>> about deriving
>>>> />/ > a microformat from SVRL to do this kind of thing?
>>>> />/ >
>>>> />/ />/ There are I believe some changes in the pipeline that would
>>>> make svrl
>>>> />/ a useful alternative to the "skeleton" model, where instead of
>>>> using a
>>>> />/ modified schematron engine to generate different output
>>>> formats, you
>>>> />/ always generate svrl and then style that appropriately, but
>>>> svrl needs
>>>> />/ to be able to record all the schematron output before that can
>>>> />/ really work, see
>>>> />/ />/
>>>> http://eccnet.eccnet.com/pipermail/schematron-love-in/2007-April/000606.html
>>>>
>>>> /
>>>> Yes, exactly.
>>>>
>>>> There might still be cases where it can be handy to generate a HTML
>>>> report in a single pass (for instance if you wanted to validate a XML
>>>> document in a browser using the xml-stylesheet PI).
>>>>
>>>> In that case, an approach that seems to be working pretty well is to
>>>> transform iso-svrl.xsl (using XSLT) into a transformation that
>>>> produces
>>>> XHTML span and divs instead of SVRL elements and attributes.
>>>>
>>>>
>>>>> /
>>>> />/ > Also, looking back at good old
>>>> />/ >
>>>> http://xml.ascc.net/schematron/1.5/report1-5/schematron-frame.html, I
>>>> />/ > see how handy that was to add node IDs to the report.
>>>> Unfortunately,
>>>> />/ > XSLT generate-id() is both implementation and execution
>>>> dependent, but
>>>> />/ > we could try to define a simple id mechanism, for instance
>>>> based on
>>>> />/ > count(preceding::node()), to identify nodes in the instance
>>>> documents.
>>>> />/ >
>>>> />/ > What do you think?
>>>> />/ >
>>>> />/ >
>>>> />/ />/ the skeleton has some id generatiing templates for exactly
>>>> that reason.
>>>> />/ <xsl:comment>MODE: GENERATE-ID-2 </xsl:comment>
>>>> />/ <xsl:text>
>>>> />/ </xsl:text>
>>>> />/ <!-- repeatable-id maker from David Carlisle. -->
>>>> />/ />/ <!--
>>>> />/ use this if you need generate IDs in separate passes,
>>>> />/ because generate-id() is not guaranteed to produce
>>>> the same
>>>> />/ results each time. These IDs are well-formed XML
>>>> NMTOKENS
>>>> />/ /
>>>> That was exactly what I had in mind, thanks!
>>>>
>>>> Eric
>>>>
>>>
>>>>
>>> Can someone tell me how to select these alternative id-generating
>>> templates?
>>> I'm getting completely confused.
>>> I see they work by specifying a mode, but I can't see how to specify
>>> which mode the generated stylesheet will use.
>>> Is it specified in something that comes from the *.sch file?
>>> Or something in iso_schematron_for_saxon.xsl?
>>>
>>> My generated stylesheet contains
>>>
>>> <div class="errors"><ul><h3/><xsl:apply-templates select="/"
>>> mode="M2"/></ul>
>>>
>>> And I think I need to change "M2" to "generate-id-2", but how?
>>>
>>> In case it helps, my pipeline that generates the validator
>>> stylesheet looks like:
>>>
>>> foo.sch is input to
>>> iso_dsdl_include.xsl, whose output goes to
>>> iso_abstract_expand.xsl, whose output goes to
>>> schematron_report.xsl (which imports
>>> iso_schematron_skeleton_for_saxon.xsl)
>>>
>>> The output of this pipeline is used as a stylesheet to validate the
>>> XML document.
>>>
>>> Thanks,
>>>
>>> Lars
>>>
>>
More information about the Schematron
mailing list