Skip to content

Commit

Permalink
That revert missed some things, should be fixed now
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Jansen committed Oct 16, 2018
1 parent c303f73 commit 69a9572
Show file tree
Hide file tree
Showing 7 changed files with 1,888 additions and 1,938 deletions.
90 changes: 37 additions & 53 deletions convert/iso_abstract_expand.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,21 @@
This is a preprocessor for ISO Schematron, which implements abstract patterns.
It also
* extracts a particular schema using an ID, where there are multiple
schemas, such as when they are embedded in the same NVDL script
* allows parameter substitution inside @context, @test, @select, @path
* experimentally, allows parameter recognition and substitution inside
text (NOTE: to be removed, for compataibility with other implementations,
please do not use this)
schemas, such as when they are embedded in the same NVDL script
* experimentally, allows parameter recognition and substitution inside
text as well as @context, @test, & @select.
This should be used after iso-dsdl-include.xsl and before the skeleton or
meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
Each kind of inclusion can be turned off (or on) on the command line.
-->

<!--
Open Source Initiative OSI - The MIT License:Licensing
[OSI Approved License]
This source code was previously available under the zlib/libpng license.
Attribution is polite.
The MIT License
Copyright (c) 2004-2010 Rick Jellife and Academia Sinica Computing Centre, Taiwan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<!--
VERSION INFORMATION
2013-09-19 RJ
* Allow macro expansion in @path attributes, eg. for sch:name/@path
2010-07-10 RJ
* Move to MIT license
2008-09-18 RJ
* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
<!--
VERSION INFORMATION
2008-09-18 RJ

This comment has been minimized.

Copy link
@ojundt

ojundt Oct 17, 2018

Contributor

Good morning @tjeb,

I deliberately excluded the converter tool update from the revert. Could you explain why we are not using the most recent version?

This comment has been minimized.

Copy link
@tjeb

tjeb Oct 17, 2018

Contributor

The xsl produced with the latest schematron version had a number of cases where errors were no longer reported. As I wasn't sure where the problem was I reverted the update for the moment.

I have now narrowed it down, and have a branch ready that reapplies the schematron update, will merge shortly.

This comment has been minimized.

Copy link
@tjeb

tjeb Oct 17, 2018

Contributor

FYI, I found the issue, there happened to be a pull request for it at schematron: Schematron/schematron#41
I have backported that change and updated the conversion to the latest version in 40516b6

* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
2008-07-29 RJ
* Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
Expand All @@ -78,6 +40,29 @@ VERSION INFORMATION
* Original written for old namespace
* http://www.topologi.com/resources/iso-pre-pro.xsl
-->
<!--
LEGAL INFORMATION
Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-->
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
Expand All @@ -100,12 +85,12 @@ VERSION INFORMATION
<!-- Normal processing rules -->
<!-- ================================================================================== -->
<!-- Output only the selected schema -->
<xslt:template match="iso:schema" >
<xslt:template match="iso:schema" >
<xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
<xslt:copy>
<xslt:copy-of select="@*" />
<xslt:apply-templates mode="iae:go" />
</xslt:copy>
</xslt:copy>
</xsl:if>
</xslt:template>

Expand Down Expand Up @@ -150,7 +135,7 @@ VERSION INFORMATION


<!-- Suppress uses of abstract patterns -->
<xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
<xslt:template match="iso:pattern[@is-a]" mode="iae:go" >

<xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>

Expand Down Expand Up @@ -245,21 +230,20 @@ VERSION INFORMATION
<xslt:template mode="iae:do-pattern" match="*">
<xslt:param name="caller"/>
<xslt:copy>
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select']">
<xslt:attribute name="{name()}">
<xslt:call-template name="iae:macro-expand">
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
</xslt:call-template>
</xslt:attribute>
</xslt:for-each>
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select']" />
<xsl:for-each select="node()">
<xsl:choose>
<!-- Experiment: replace macros in text as well, to allow parameterized assertions
and so on, without having to have spurious <iso:value-of> calls and multiple
delimiting.
NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
delimiting -->
<xsl:when test="self::text()">
<xslt:call-template name="iae:macro-expand">
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
Expand Down
Loading

0 comments on commit 69a9572

Please sign in to comment.