Skip to content

Commit

Permalink
Merge branch 'iso-schematron-new'
Browse files Browse the repository at this point in the history
  • Loading branch information
JDziurlaj committed Feb 7, 2021
2 parents 4aae7dd + 8eb7b6a commit d51f1c5
Show file tree
Hide file tree
Showing 16 changed files with 2,178 additions and 1,617 deletions.
Binary file modified lib/saxon9he.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cladonia.xml.schematron;

import net.sf.saxon.event.MessageEmitter;
import net.sf.saxon.serialize.MessageEmitter;
import net.sf.saxon.event.Receiver;
import net.sf.saxon.trans.XPathException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public SchematronMessageOutputStream(ExchangerEditor _editor, SchematronTraceLis
this.editor = _editor;
this.schematronTraceListener = schematronTraceListener;
this.systemId = systemId;

/*SwingUtilities.invokeLater(new Runnable() {
/*
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
editor.getOutputPanel().startCheck( "SCHEMATRON", "Schematron Version ["+FileUtilities.getSchematronVersion()+"]...");
}
});*/

});
*/
}

@Override
Expand Down
26 changes: 19 additions & 7 deletions src/com/cladonia/xml/schematron/SchematronTraceListener.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
package com.cladonia.xml.schematron;

import java.io.OutputStream;
import java.io.PrintStream;

import javax.swing.SwingUtilities;
import javax.xml.transform.SourceLocator;

import com.cladonia.xngreditor.ExchangerEditor;

import net.sf.saxon.event.MessageEmitter;
import net.sf.saxon.Controller;
import net.sf.saxon.lib.Logger;
import net.sf.saxon.serialize.MessageEmitter;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.om.Item;
import net.sf.saxon.s9api.MessageListener;
import net.sf.saxon.s9api.XdmNode;
import net.sf.saxon.tinytree.TinyNodeImpl;
import net.sf.saxon.tinytree.TinyTextImpl;
import net.sf.saxon.tinytree.TinyTree;
import net.sf.saxon.tree.tiny.TinyNodeImpl;
import net.sf.saxon.tree.tiny.TinyTextImpl;
import net.sf.saxon.tree.tiny.TinyTree;
import net.sf.saxon.trace.InstructionInfo;
import net.sf.saxon.trace.TraceListener;
import net.sf.saxon.lib.TraceListener;
import net.sf.saxon.type.Type;
import net.sf.saxon.type.TypeHierarchy;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class SchematronTraceListener implements TraceListener {

Expand Down Expand Up @@ -92,7 +96,7 @@ public void leave(InstructionInfo arg0) {

}

@Override
// @Override
public void open() {
//System.out.println("open");

Expand All @@ -106,7 +110,7 @@ public void startCurrentItem(Item item) {
setCurrentLineNumber(((TinyTextImpl)item).getLineNumber());
setCurrentColumn(((TinyTextImpl)item).getColumnNumber());
}
else if(item instanceof net.sf.saxon.tinytree.TinyNodeImpl) {
else if(item instanceof net.sf.saxon.tree.tiny.TinyNodeImpl) {
//System.out.println("startCurrentItem: "+((TinyNodeImpl)item).getLocalPart()+ " - line: "+((TinyNodeImpl)item).getLineNumber());
setCurrentLineNumber(((TinyNodeImpl)item).getLineNumber());
setCurrentColumn(((TinyNodeImpl)item).getColumnNumber());
Expand Down Expand Up @@ -153,4 +157,12 @@ public int getErrorCounter() {
public void incrementErrorCounter() {
this.errorCounter++;
}

public void setOutputDestination(Logger logger){
throw new NotImplementedException();
}

public void open(Controller controller){
open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,59 @@
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
* experimentally, allows parameter recognition and substitution inside
text as well as @context, @test, & @select.
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)
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.
-->
<!--
VERSION INFORMATION
2008-09-18 RJ
* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)

<!--
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)
2008-07-29 RJ
* Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
Expand All @@ -40,35 +78,11 @@
* 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"
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"


xmlns:iae="http://www.schematron.com/namespace/iae"

>
Expand All @@ -86,12 +100,12 @@
<!-- 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 @@ -136,7 +150,7 @@


<!-- 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 @@ -231,20 +245,21 @@
<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']">
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
<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']" />
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
<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 -->
delimiting.
NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
<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 Expand Up @@ -293,4 +308,6 @@
</xsl:choose>
</xslt:template>



</xslt:stylesheet>
Loading

0 comments on commit d51f1c5

Please sign in to comment.