XForms' transform function

Resending - I think the previous version of this e-mail has got stuck in the pipes because I put the xform as an attachment.


I have been experimenting with demonstrating Schematron validation within XForms by the use of the proposed transform function. I have been using XSLTForms beta3 and have a rather limited example which uses the textual result from the XSLT 1.0 skeleton implementation. Seeing as XSLTForms' transform function returns a string serialization of the result of the transform I cannot use the SVRL representation of a Schematron report which would, if available as an XML tree, provide more options for presentation and logic/behavior than the basic text report. However, it does prove that it can work all be it that the 'complied' schema can only be accessed via a URI.

I am still looking for an implementation that'll firstly let me store the compiled schema in an XForms instance and ultimately allow me to daisy-chain the compilation transforms, across an number of instances, so that I can create a Schematron rules editor in XForms and have the schema compiled and applied to a test source document upon DOMSubtreeModified events dispatched from the schema instance. The nearest option I can currently see working is to use Orbeon's xxforms:call-xpl() function and implement the Schematron compilation pipeline externally to XForms but that's not what I'm after.

I have included below the fledgling form so that you can see the string of instances I'll in order to compile the schema. It's all rather a hack at the moment but I'm planning on making it look a bit more presentable.


Regards

Philip Fennell
Consultant
MarkLogic Corporation

One Kingdom Street
Paddington Central
London W2 6BD
United Kingdom

Mobile: +44 (0) 7824 830 866 
Tel:    +44 (0) 203 402 3619

email  Philip.Fennell@marklogic.com
web    www.marklogic.com




<?oxygen NVDLSchema="../../schemas/nvdl/xhtml-xforms11.nvdl"?>
<?xml-stylesheet href="/resources/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html 	xmlns="http://www.w3.org/1999/xhtml" 
		xmlns:atom="http://www.w3.org/2005/Atom" 
		xmlns:ev="http://www.w3.org/2001/xml-events" 
		xmlns:iso="http://purl.oclc.org/dsdl/schematron" 
		xmlns:svrl="http://purl.oclc.org/dsdl/svrl" 
		xmlns:xf="http://www.w3.org/2002/xforms" 
		xmlns:xs="http://www.w3.org/2001/XMLSchema" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
		xml:lang="en" 
		lang="en">
	<head>
		<title>XForms + Schematron</title>
		<meta http-equiv="content-language" content="en" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<!--<link href="/resources/css/xforms.css" media="all" rel="stylesheet"/>-->

		<xf:model id="content">
			
			<xf:instance id="source">
				<atom:feed xmlns:atom="http://www.w3.org/2005/Atom">
					<atom:title>Test Feed</atom:title>
					<atom:id>urn:test:atom-feed</atom:id>
					<atom:updated>2011-05-06T19:10:00</atom:updated>
				</atom:feed>
			</xf:instance>
			
			<xf:bind id="feedTitle" nodeset="atom:title"/>
			<xf:bind id="feedId" nodeset="atom:id"></xf:bind>
			<xf:bind id="feedUpdated" nodeset="atom:updated"/>
		</xf:model>
		
		<xf:model id="rules">
			
			<xf:instance id="schema">
				<iso:schema xmlns:iso="http://purl.oclc.org/dsdl/schematron">
					<iso:ns prefix="atom" uri="http://www.w3.org/2005/Atom"/>
					<iso:title>Simple Atom Feed Rules</iso:title>
					<iso:pattern>
						<iso:title>Atom Feed Root</iso:title>
						<iso:rule context="/">
							<iso:assert test="atom:feed">The document root must be an atom:feed element.</iso:assert>
						</iso:rule>
					</iso:pattern>
					<iso:pattern>
						<iso:title>Required elements of an Atom Feed</iso:title>
						<iso:rule context="/atom:feed">
							<iso:assert test="atom:title">atom:title is missing, this is a required element.</iso:assert>
							<iso:assert test="atom:id">atom:id is missing, this is a required element.</iso:assert>
							<iso:assert test="atom:updated">atom:updated is missing, this is a required element.</iso:assert>
						</iso:rule>
					</iso:pattern>
				</iso:schema>
			</xf:instance>
			
			<xf:instance id="dsdlInclude">
				<iso:schema xmlns:iso="http://purl.oclc.org/dsdl/schematron"/>
			</xf:instance>
			
			<xf:instance id="abstractExpand">
				<iso:schema xmlns:iso="http://purl.oclc.org/dsdl/schematron"/>
			</xf:instance>
			
			<xf:instance id="compiledSchema">
				<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			</xf:instance>
			
			<xf:instance id="svrlReport">
				<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl"> </svrl:schematron-output>
			</xf:instance>
		</xf:model>
	</head>
	<body>
		<div id="view">
			<h1>Source</h1>
			<h2>
				<xf:output value="name(instance('source'))">
					<xf:label>Document Root</xf:label>
				</xf:output>
			</h2>
			
			<div>
				<xf:output bind="feedTitle">
					<xf:label>Title</xf:label>
				</xf:output>
			</div>
			<div>
				<xf:output bind="feedId">
					<xf:label>Id</xf:label>
				</xf:output>
			</div>
			<div>
				<xf:output bind="feedUpdated">
					<xf:label>Updated</xf:label>
				</xf:output>
			</div>
		</div>
		<div id="results">
			<div>
				<pre>
					<xf:output ref="instance('svrlReport')"/>
				</pre>
			</div>
			<div>
				<xf:trigger>
					<xf:label>Validate Rules</xf:label>
					<xf:action ev:event="DOMActivate">
						<!--<xf:insert origin="transform(instance('source'), '/resources/schemas/schematron/atom-feed.xsl')" position="after" nodeset="." context="instance('svrlReport')"/>-->
						<xf:setvalue ref="instance('svrlReport')" 
							value="substring-after(substring-before(
								transform(instance('source'), '/resources/schemas/schematron/vanilla-atom-feed.xsl'), 
									'&lt;/'), '&gt;')"/>
					</xf:action>
				</xf:trigger>
			</div>
		</div>
	</body>
</html>

Received on Wednesday, 11 May 2011 05:07:33 UTC