XForms' transform function
Philip Fennell <[email protected]> Tue, 10 May 2011 22:07:07 -0700
| Newsgroups | gmane.comp.web.xforms |
|---|---|
| Message-ID | <[email protected]> |
Resending - I think the previous version of this e-mail has got stuck in th= e pipes because I put the xform as an attachment. I have been experimenting with demonstrating Schematron validation within X= Forms by the use of the proposed transform function. I have been using XSLT= Forms 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 ca= nnot use the SVRL representation of a Schematron report which would, if ava= ilable as an XML tree, provide more options for presentation and logic/beha= vior than the basic text report. However, it does prove that it can work al= l 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 c= ompiled schema in an XForms instance and ultimately allow me to daisy-chain= the compilation transforms, across an number of instances, so that I can c= reate 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 i= s 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 th= e 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=20 Tel: +44 (0) 203 402 3619 email=A0 [email protected] web=A0=A0=A0 www.marklogic.com <?oxygen NVDLSchema=3D"../../schemas/nvdl/xhtml-xforms11.nvdl"?> <?xml-stylesheet href=3D"/resources/xsltforms/xsltforms.xsl" type=3D"text/x= sl"?> <html xmlns=3D"http://www.w3.org/1999/xhtml"=20 xmlns:atom=3D"http://www.w3.org/2005/Atom"=20 xmlns:ev=3D"http://www.w3.org/2001/xml-events"=20 xmlns:iso=3D"http://purl.oclc.org/dsdl/schematron"=20 xmlns:svrl=3D"http://purl.oclc.org/dsdl/svrl"=20 xmlns:xf=3D"http://www.w3.org/2002/xforms"=20 xmlns:xs=3D"http://www.w3.org/2001/XMLSchema"=20 xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"=20 xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"=20 xml:lang=3D"en"=20 lang=3D"en"> <head> <title>XForms + Schematron</title> <meta http-equiv=3D"content-language" content=3D"en" /> <meta http-equiv=3D"cache-control" content=3D"no-cache" /> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" = /> <!--<link href=3D"/resources/css/xforms.css" media=3D"all" rel=3D"stylesh= eet"/>--> <xf:model id=3D"content"> =09 <xf:instance id=3D"source"> <atom:feed xmlns:atom=3D"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> =09 <xf:bind id=3D"feedTitle" nodeset=3D"atom:title"/> <xf:bind id=3D"feedId" nodeset=3D"atom:id"></xf:bind> <xf:bind id=3D"feedUpdated" nodeset=3D"atom:updated"/> </xf:model> =09 <xf:model id=3D"rules"> =09 <xf:instance id=3D"schema"> <iso:schema xmlns:iso=3D"http://purl.oclc.org/dsdl/schematron"> <iso:ns prefix=3D"atom" uri=3D"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=3D"/"> <iso:assert test=3D"atom:feed">The document root must be an atom:fee= d element.</iso:assert> </iso:rule> </iso:pattern> <iso:pattern> <iso:title>Required elements of an Atom Feed</iso:title> <iso:rule context=3D"/atom:feed"> <iso:assert test=3D"atom:title">atom:title is missing, this is a req= uired element.</iso:assert> <iso:assert test=3D"atom:id">atom:id is missing, this is a required = element.</iso:assert> <iso:assert test=3D"atom:updated">atom:updated is missing, this is a= required element.</iso:assert> </iso:rule> </iso:pattern> </iso:schema> </xf:instance> =09 <xf:instance id=3D"dsdlInclude"> <iso:schema xmlns:iso=3D"http://purl.oclc.org/dsdl/schematron"/> </xf:instance> =09 <xf:instance id=3D"abstractExpand"> <iso:schema xmlns:iso=3D"http://purl.oclc.org/dsdl/schematron"/> </xf:instance> =09 <xf:instance id=3D"compiledSchema"> <xsl:transform xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"/> </xf:instance> =09 <xf:instance id=3D"svrlReport"> <svrl:schematron-output xmlns:svrl=3D"http://purl.oclc.org/dsdl/svrl"> = </svrl:schematron-output> </xf:instance> </xf:model> </head> <body> <div id=3D"view"> <h1>Source</h1> <h2> <xf:output value=3D"name(instance('source'))"> <xf:label>Document Root</xf:label> </xf:output> </h2> =09 <div> <xf:output bind=3D"feedTitle"> <xf:label>Title</xf:label> </xf:output> </div> <div> <xf:output bind=3D"feedId"> <xf:label>Id</xf:label> </xf:output> </div> <div> <xf:output bind=3D"feedUpdated"> <xf:label>Updated</xf:label> </xf:output> </div> </div> <div id=3D"results"> <div> <pre> <xf:output ref=3D"instance('svrlReport')"/> </pre> </div> <div> <xf:trigger> <xf:label>Validate Rules</xf:label> <xf:action ev:event=3D"DOMActivate"> <!--<xf:insert origin=3D"transform(instance('source'), '/resources/sc= hemas/schematron/atom-feed.xsl')" position=3D"after" nodeset=3D"." context= =3D"instance('svrlReport')"/>--> <xf:setvalue ref=3D"instance('svrlReport')"=20 value=3D"substring-after(substring-before( transform(instance('source'), '/resources/schemas/schematron/vanill= a-atom-feed.xsl'),=20 '</'), '>')"/> </xf:action> </xf:trigger> </div> </div> </body> </html>