Giter VIP home page Giter VIP logo

alaincouthures / xsltforms Goto Github PK

View Code? Open in Web Editor NEW
37.0 12.0 19.0 4.4 MB

XForms to XHTML+Javascript (AJAX) conversion based on a unique XSL transformation. Suitable server-side (PHP) or client-side (Google Chrome, Edge, Internet Explorer, Mozilla FireFox, Opera, Safari) browser treatment where an XSLT 1.0 engine is available

XSLT 12.39% PHP 3.20% HTML 51.20% JavaScript 29.91% CSS 3.10% Java 0.18% Batchfile 0.01%

xsltforms's Introduction

XSLTForms Source Management

About

XForms to XHTML+Javascript (AJAX) conversion based on a unique XSL transformation. Suitable server-side (PHP) or client-side (Internet Explorer, Mozilla FireFox, Opera, Safari) browser treatment where an XSLT 1.0 engine is available.

Source files

XSLTForms is composed of the following files :

  • xsltforms.xsl
  • xsltforms.js
  • xsltforms.css

Those files are relatively big and complex. They are generated from numerous components.

Components

Components are elementary source elements. Each is stored as an XML document with metadata, unit tests and the source itself.

Components can be composed of other components.

The main components for XSLTForms are :

  • xsltforms.xsl.xml
  • xsltforms.js.xml
  • xsltforms.css.xml

tXs

tXs is an XML script engine written in PHP 5. It is composed of an unique file named txs.php while scripts usually have a .txs extension.

First, install Apache+PHP5 locally, and activate the Rewrite Module.

Get all the XSLTForms files from SVN server into a subfolder (named XSLTFormsRoot for example) of the DocumentRoot folder (a .htaccess file should be present in the XSLTFormsRoot folder).

To check that tXs is correctly installed, get http://localhost/XSLTFormsRoot/txs/txs.php with a browser : the default script, named echo.txs should run and the response should be an XHTML page with tXs Echo Script as title.

To check that URL rewriting is correctly installed, get http:/localhost/XSLTFormsRoot/txs/echo.txs with a browser : the response should be an XHTML page with tXs Echo Script as title.

Dynamic build of XSLTForms files

Because of URL rewriting, .js, .xsl and .css files are not directly delivered. Instead, the cm.txs script is run : it collects every source within the corresponding component and sub-components. For the browser, it's exactly as if it was a real file.

So, main files are obtains with URLs like those :

  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.xsl
  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.js
  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.css

Static build of XSLTForms files

To build a component, just add ?build at the end of the component URI. The resulting file is written in the build folder at the same level as the src folder.

So, main files are built with URLs like those :

  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.xsl?build
  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.js?build
  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.css?build

Unit tests

Unit tests are based on JsUnitTest.

To run associated unit tests for a component, just add ?ut at the end of the component URI.

Examples :

  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.js?ut
  • http://localhost/XSLTFormsRoot/trunk/src/xsltforms.xsl?ut
  • http://localhost/XSLTFormsRoot/trunk/src/js/types/TypeDefs.js?ut

Test Suites

Test Suites are stored separately from components in the testsuite folder.

To run tests with trunk or branches components, the testsuite path has to be added after the src path to main components (xsltforms.*.xml). tXs scripts are there to adapt each test to XSLTForms requirements (add the processing instruction for the XSLT transformation, change the submission links, ...).

Examples :

  • http://localhost/XSLTFormsRoot/trunk/src/testsuite/Xforms1.1/Edition1/driverPages/html/
  • http://localhost/XSLTFormsRoot/trunk/src/testsuite/Xforms1.1/Edition1/Chapt02/2.4.a.xhtml

Feature switching

Feature switching is based on files named *options.xml to be placed in the same folder as main components (xsltforms.*.xml). Options are processing instructions to add in the XML document to permit the XSLT transformation to interpret them.

Example : http://localhost/XSLTFormsRoot/trunk/src/nocssoptions.xml.

Then, /*options has to be put just before /testsuite in the URL to activate the corresponding options.

Example : http://localhost/XSLTFormsRoot/trunk/src/nocssoptions/testsuite/Xforms1.1/Edition1/Chapt02/2.4.a.xhtml

xsltforms's People

Contributors

alaincouthures avatar epost avatar hfmanson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xsltforms's Issues

Improve JavaScript and Node.js ecosystem friendliness

Bonjour Alain! I created a javascript + node.js based tool for 'unpacking' your js.xml files back into plain javascript: https://github.com/epost/unjsxml. I needed this so I can work with your sources in my editor (which happens to be emacs). I think it would be great if we could work towards a build that doesn't absolutely require tools like PHP and httpd or stuff like that.

This is just a first step, but it should be fairly easy to additional functionality. For instance, running a webserver is just a few additional lines of js code. Qu'est-ce-que t'en penses?

concat without end parenthesis

Hi Alain,

I've found a weird one. I may be wrong but here I go:

I have the following code, that actually works without the end parenthesis ")" at the end of the concat function call:
<xf:repeat ref="instance('paginas')//*:group" >
<a href="{concat('/mockup/web/', ../key, '/' ,key,'.html'}" target="mockup-frame" name="{key}" >
...

if I add the end parenthesis, like this, it breaks:
<a href="{concat('/mockup/web/', ../key, '/' ,key,'.html')}" target="mockup-frame" name="{key}" >

I thought it could be something weird, but then I saw this one working with the same fault, it does n't work if I add the end parenthesis on the concat line:
<xf:repeat ref="instance('paginas')//*:menu" >
<li>
<a href="{concat('#', target}" >
<xf:output ref="name" />
</a>
</li>
</xf:repeat>

As you can see, I have no urgent need for this to be fixed but it may bug other ones (or me..). The script version is 1.3 (details below).

XSLTForms 1.3 (652)
XForms 1.1+ with XPath 1.0+ Engine

Hope everything is Ok, thanks for all Alain.

build process not working

The build process (i.e. in which you set up a PHP web application and use it to generate xsltforms.js etc. from components) is broken because it doesn't reflect the directory layout since the switch from svn to git. I think the .htaccess file, at least, needs to be updated.

CSV support

When I try to create an XForms instance from a CSV file (mediatype="text/csv; separator=,; header=present") I get an error in Firefox (Ubuntu 14.04):

Unsupported mediatype 'text/comma-separated-values'

However, in Chrome, the CSV is parsed correctly as text/csv. Maybe an additional check could be added for text/comma-separated-values as a valid mediatype?

Using double apostrophe to espacing

Hello @AlainCouthures
I have xform which is generated and it uses double apostrophes to espace apostrophe.
I have done some research about it, and it looks like that is proper literal in XPath 2.0 http://www.w3.org/TR/xpath20/#id-literals
http://stackoverflow.com/questions/2887281/escape-single-quote-in-xslt-concat-function

Now i have code like that:

<xf:input ref="xxf:evaluate(concat('instance(''my-instance'')/document', my-xpath))">
<xf:label>...</xf:label>
</xf:input>

and this is inpossible to parse properly in XSLTForms.
Could you please look in it? Or give me some advices how to parse it?

Greetings

Support for JSON-LD

I am looking into XSLTForm's support for JSON (a very nice feature!), and I am particularly interested in using JSON-LD[1]. However, it appears that the "@" character, which is used in JSON-LD in the @context and @id keywords, is causing the json2xml method to break.

Following the "JSON for XForms" paper presented at XML Prague, I would expect JSON names containing characters that are not permitted in XML names to be represented using the exml:fullname attribute. Reading the code (in XFInstance.js.xml), I wasn't able to tell where the validity of XML names was being checked, or how to modify the code in order to handle the "@" character.

[1] http://www.w3.org/TR/json-ld/

Some fixes and improves

Hello @AlainCouthures
I'm working in some big project with xforms and I'm using XSLTForms to parse it and display in browser. During this work I found some problems with library and fixed some things. Additionaly I had added few features that I needed and I thought it could be useful for other people.

But.. i don't understand way of "compiling" this from source, so I have made changes in my repo only in "build" version.
If you think that is ok, include it in your repo in right way.

Diff: master...rysi3k:master

Greetings

iText binding issues with ODK based xform

Hi Alain,

I have been looking far a wide for a JavaScript based XForms editor. We are using some XForms based on a older version of ODK's JavaRosa using iText for multiple languages. I have played around with the name space but its still throwing an error.

I was hopping for some insight as to where I should be looking if I'm going to need to fork this to support our JavaRosa flavor. Our XFrom code is pasted below:

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
  <h:head>
    <h:title>QuickForm</h:title>
    <model>
<!-- COMMENT GitHub Posted -->	
	<instance>
        <data id="QuickForm" category="Web Only" tag="Data Collection" revision_date="2019-11-08">
          <device_id/>
          <subscriber_id/>
          <sim_id/>
          <AlarmStatus>NA</AlarmStatus>
          <Form_Version>08NOV2019</Form_Version>
          <SubjectName/>
          <Category/>
          <SubCategory1/>
          <Date/>
          <Location>GPS</Location>
          <GPS/>
          <MGRS/>
          <Latitude/>
          <Longitude/>
          <LocationText/>
          <Photo/>
           <Comment/>
          <AudioComment/>
          <VideoNote/>
          <SubmittedBy/>
        </data>
      </instance>
      <itext>
        <translation lang="eng">
          <text id="/data/AlarmStatus:label">
            <value>Alarm Status</value>
          </text>
          <text id="/data/AlarmStatus:hint">
            <value>Form Revised 08NOV2019</value>
          </text>
          <text id="/data/AlarmStatus:option0">
            <value>High High (Critical)</value>
          </text>
          <text id="/data/AlarmStatus:option1">
            <value>High</value>
          </text>
          <text id="/data/AlarmStatus:option2">
            <value>Neutral (no alarm)</value>
          </text>
          <text id="/data/AlarmStatus:option3">
            <value>Positive (Noteworthy)</value>
          </text>
          <text id="/data/AlarmStatus:option4">
            <value>Positive High (Very Noteworthy)</value>
          </text>
          <text id="/data/SubjectName:label">
            <value>Subject Name</value>
          </text>
          <text id="/data/SubjectName:hint">
            <value>Subject Name</value>
          </text>
          <text id="/data/Category:label">
            <value>Category</value>
          </text>
          <text id="/data/Category:hint">
            <value>From large button interface, select main category</value>
          </text>
          <text id="/data/SubCategory1:label">
            <value>SubCategory1 or Detail</value>
          </text>
          <text id="/data/SubCategory1:hint">
            <value>From large button interface, select the detail or task</value>
          </text>
          <text id="/data/Date:label">
            <value>Date</value>
          </text>
          <text id="/data/Date:hint">
            <value>Current date and time.  Modify here if necessary</value>
          </text>
          <text id="/data/Location:label">
            <value>Location obtained from</value>
          </text>
          <text id="/data/Location:hint">
            <value></value>
          </text>
          <text id="/data/Location:option0">
            <value>GPS location from cellphone</value>
          </text>
          <text id="/data/Location:option1">
            <value>Manually enter MGRS</value>
          </text>
          <text id="/data/Location:option2">
            <value>Manually enter Latitude x Longitude</value>
          </text>
          <text id="/data/Location:option3">
            <value>Text description of the location</value>
          </text>
          <text id="/data/GPS:label">
            <value>GPS</value>
          </text>
          <text id="/data/GPS:hint">
            <value></value>
          </text>
          <text id="/data/MGRS:label">
            <value>MGRS</value>
          </text>
          <text id="/data/MGRS:hint">
            <value>Enter 10-digit or 8-digit MGRS coordinates</value>
          </text>
          <text id="/data/Latitude:label">
            <value>Latitude</value>
          </text>
          <text id="/data/Latitude:hint">
            <value>enter digit Latitude here (Longitude on next screen)</value>
          </text>
          <text id="/data/Longitude:label">
            <value>Longitude</value>
          </text>
          <text id="/data/Longitude:hint">
            <value>enter digital Longitude</value>
          </text>
          <text id="/data/LocationText:label">
            <value>Enter a description of the location in text.  Please use this option ONLY if other coordinate information is unavailable.</value>
          </text>
          <text id="/data/LocationText:hint">
            <value></value>
          </text>
          <text id="/data/Photo:label">
            <value>Photo 1</value>
          </text>
          <text id="/data/Photo:hint">
            <value>A maximum of 5 photos can be captured in this form</value>
          </text>
          <text id="/data/Comment:label">
            <value>Report Text</value>
          </text>
          <text id="/data/Comment:hint">
            <value>Optional:  Add any comments here that help describe the captured photos</value>
          </text>
          <text id="/data/AudioComment:label">
            <value>Audio</value>
          </text>
          <text id="/data/AudioComment:hint">
            <value>Include audio that will be helpful to the report</value>
          </text>
          <text id="/data/VideoNote:label">
            <value>Video</value>
          </text>
          <text id="/data/VideoNote:hint">
            <value>Include video that will be helpful to the report</value>
          </text>
          <text id="/data/SubmittedBy:label">
            <value>Submitted By</value>
          </text>
          <text id="/data/SubmittedBy:hint">
            <value>enter your name or initials as instructed</value>
          </text>
        </translation>
      </itext>
      <bind nodeset="/data/device_id" type="string" jr:preload="property" jr:preloadParams="deviceid"/>
      <bind nodeset="/data/subscriber_id" type="string" jr:preload="property" jr:preloadParams="subscriberid"/>
      <bind nodeset="/data/sim_id" type="string" jr:preload="property" jr:preloadParams="simserial"/> 
      <bind nodeset="/data/AlarmStatus"/>
      <bind nodeset="/data/Form_Version"/>
      <bind nodeset="/data/SubjectName" type="string" required="true()"/>
      <bind nodeset="/data/Category" type="string" required="true()"/>
      <bind nodeset="/data/SubCategory1" type="string"/>
      <bind nodeset="/data/Date" type="dateTime" required="true()"/>
      <bind nodeset="/data/Location" type="select1" required="true()"/>
      <bind nodeset="/data/GPS" type="geopoint" relevant="(/data/Location = 'GPS')"/>
      <bind nodeset="/data/MGRS" type="string" relevant="(/data/Location = 'MGRS')"/>
      <bind nodeset="/data/Latitude" type="decimal" relevant="(/data/Location = 'LatLong')" constraint="(. &gt; -91 and . &lt; 91)"/>
      <bind nodeset="/data/Longitude" type="decimal" relevant="(/data/Location = 'LatLong')" constraint="(. &gt; -181 and . &lt; 181)"/>
      <bind nodeset="/data/LocationText" type="string" relevant="(/data/Location = 'LocationText')"/>
      <bind nodeset="/data/Photo" type="binary"/>
      <bind nodeset="/data/Comment" type="string"/>
      <bind nodeset="/data/AudioComment" type="binary"/>
      <bind nodeset="/data/VideoNote" type="binary"/>
      <bind nodeset="/data/SubmittedBy" type="string"/>
    </model>
  </h:head>
  <h:body>
    <select1 ref="/data/AlarmStatus">
      <label ref="jr:itext('/data/AlarmStatus:label')"/>
      <hint ref="jr:itext('/data/AlarmStatus:hint')"/>
      <item>
        <label ref="jr:itext('/data/AlarmStatus:option0')"/>
        <value>HiHi</value>
      </item>
      <item>
        <label ref="jr:itext('/data/AlarmStatus:option1')"/>
        <value>Hi</value>
      </item>
      <item>
        <label ref="jr:itext('/data/AlarmStatus:option2')"/>
        <value>Neutral</value>
      </item>
      <item>
        <label ref="jr:itext('/data/AlarmStatus:option3')"/>
        <value>Positive</value>
      </item>
      <item>
        <label ref="jr:itext('/data/AlarmStatus:option4')"/>
        <value>PositiveHi</value>
      </item>
    </select1>
    <input ref="/data/SubjectName">
      <label ref="jr:itext('/data/SubjectName:label')"/>
      <hint ref="jr:itext('/data/SubjectName:hint')"/>
    </input>
    <input ref="/data/Category">
      <label ref="jr:itext('/data/Category:label')"/>
      <hint ref="jr:itext('/data/Category:hint')"/>
    </input>
    <input ref="/data/SubCategory1">
      <label ref="jr:itext('/data/SubCategory1:label')"/>
      <hint ref="jr:itext('/data/SubCategory1:hint')"/>
    </input>
    <input ref="/data/Date">
      <label ref="jr:itext('/data/Date:label')"/>
      <hint ref="jr:itext('/data/Date:hint')"/>
    </input>
    <select1 ref="/data/Location">
      <label ref="jr:itext('/data/Location:label')"/>
      <hint ref="jr:itext('/data/Location:hint')"/>
      <item>
        <label ref="jr:itext('/data/Location:option0')"/>
        <value>GPS</value>
      </item>
      <item>
        <label ref="jr:itext('/data/Location:option1')"/>
        <value>MGRS</value>
      </item>
      <item>
        <label ref="jr:itext('/data/Location:option2')"/>
        <value>LatLong</value>
      </item>
      <item>
        <label ref="jr:itext('/data/Location:option3')"/>
        <value>LocationText</value>
      </item>
    </select1>
    <input ref="/data/GPS">
      <label ref="jr:itext('/data/GPS:label')"/>
      <hint ref="jr:itext('/data/GPS:hint')"/>
    </input>
    <input ref="/data/MGRS">
      <label ref="jr:itext('/data/MGRS:label')"/>
      <hint ref="jr:itext('/data/MGRS:hint')"/>
    </input>
    <input ref="/data/Latitude">
      <label ref="jr:itext('/data/Latitude:label')"/>
      <hint ref="jr:itext('/data/Latitude:hint')"/>
    </input>
    <input ref="/data/Longitude">
      <label ref="jr:itext('/data/Longitude:label')"/>
      <hint ref="jr:itext('/data/Longitude:hint')"/>
    </input>
    <input ref="/data/LocationText">
      <label ref="jr:itext('/data/LocationText:label')"/>
      <hint ref="jr:itext('/data/LocationText:hint')"/>
    </input>
    <upload ref="/data/Photo" mediatype="image/*">
      <label ref="jr:itext('/data/Photo:label')"/>
      <hint ref="jr:itext('/data/Photo:hint')"/>
    </upload>
    <input ref="/data/Comment">
      <label ref="jr:itext('/data/Comment:label')"/>
      <hint ref="jr:itext('/data/Comment:hint')"/>
    </input>
    <upload ref="/data/AudioComment" mediatype="audio/*">
      <label ref="jr:itext('/data/AudioComment:label')"/>
      <hint ref="jr:itext('/data/AudioComment:hint')"/>
    </upload>
    <upload ref="/data/VideoNote" mediatype="video/*">
      <label ref="jr:itext('/data/VideoNote:label')"/>
      <hint ref="jr:itext('/data/VideoNote:hint')"/>
    </upload>
    <input ref="/data/SubmittedBy">
      <label ref="jr:itext('/data/SubmittedBy:label')"/>
      <hint ref="jr:itext('/data/SubmittedBy:hint')"/>
    </input>
  </h:body>
</h:html>

XSLTForms.xsl transform drops the XHTML namespace

I've recently upgraded to the latest version of XSLTForms (rev.638) and discovered that the output of the stylesheet does not use the XHTML namespace. By processing my XHTML + XForms document with XSLTForms, I've stripped the namespace from it. This was a problem for me because I am executing XSLTForms.xsl in an XProc pipeline, server-side, rather than in the browser, and subsequent stages in the pipeline were expecting an XHTML document.

My work-around is to rename the default namespace from "" back to "http://www.w3.org/1999/xhtml" after the XSLTForms.xsl transformation:

<p:namespace-rename from="" to="http://www.w3.org/1999/xhtml" apply-to="elements"/>

But I wonder if the elimination of the XHTML namespace by XSLTForms.xsl is intentional, or if it's just a bug? If intentional, what does it achieve?

New version of xsltforms 1.0RC2 breaks application

Hi, I have a MarkLogic application which uses xforms in a few places. Recently we started getting users with IE11 and found that the forms broke (null pointer exception in xsltforms.js) however the version of xsltforms used in the application was quite old (2-3 years old I guess). As I test I installed the latest version of xsltforms. Unfortunately I see a new exception but across all browsers, here are the details
Appreciate any tips you can give me.
thanks
Joe

XDMP-ARGTYPE: (err:XPTY0004) fn:contains(<xsl:attribute name="class" select="logo-header float_left">, "{") -- arg1 is not of type xs:string?
in /resources/xsltforms/xsltforms.xsl, at 4057:3 [XSLT]
fn:context-item() = fn:doc("")/default:html/default:body/default:div/default:div/default:div[1]/default:div[2]/default:a/default:img/@Class
fn:position() = 2
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 4544:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 271:0 [XSLT]
in /resources/xsltforms/xsltforms.xsl, at 220:0,
in xdmp:xslt-invoke("/resources/xsltforms/xsltforms.xsl", document{<title>XXXXXX</title><meta http-equiv="Conte...}, map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry key="baseuri"><map:value xsi:type="xs:string">/resour.../map:map)) [XSLT]

Problem with upload field

Hello,
I have that field:

<xf:upload
    _bind="ID14" ref="wnio:ID14">
    <xf:filename ref="../@nazwaPliku"/>
    <xf:label>
    <span/>
    </xf:label>
</xf:upload>

XSLTForms renders that field propertly but after select file there there are alert with "Error". I have fixed this with modifing XsltForms_binding.prototype.evaluate to that:

XsltForms_binding.prototype.evaluate = function() {
    return this.bind_evaluate.apply(this, arguments);
};

I don't know it's ok? it's bug or I missed something?

Regards

Chrome 34 issue repeats when multistep form is submitted

Revision 594 fixes error in Chrome, it's great.

But I have some multistep forms, which had similar error alerts when they was submitted:
screen shot 2014-04-30 at 12 46

I found it's necessary to fix XsltForms_globals.validate_ method like XsltForms_instance.prototype.validation_ was fixed in rev. 594
(97657f9): nodeName must be checked if it is not "xmlns".

I'm not sure if it's a common problem (code of my library's instance is modified), but it helps for me.

[Feature Request] Advanced JavaScript integration

Hi Alain,

I have been working with XSLTForms 1.3 recently, and it is a very useful tool, so thank you for your work.

Coming from JavaScript, I quickly found several aspects where a better JavaScript integration would allow for more uses, form submissions for example, as far as I understand (and there's a big chance I am wrong), the data you get from a submission can be set to an instance, can replace the page, or can be opened as a new page (tab/window).

It would have been nice if there was an option to pass the data to a JavaScript function, so the developer can use that data any way they like.

Another thing I have tried to do and I think it's not possible yet (or maybe I just couldn't figure out how to do it), is to set a uri to the newly opened window from the submission, which I think it can be handy for sharing for example.

Please let me know if there's way to do these, and if not, I am happy to make PRs with these features.

Why in code are removeAttribute maxLength and size?

Hello,
I trying parsing forms generated in other software but I have some problems with some custom attributes.
I have that code:

<xf:input
_bind="ID11"
ref="wnio:ID11" xxforms:size="10">
<xf:label>
<span/>
</xf:label>
</xf:input>

or

<xf:textarea
_bind="ID27"
ref="wnio:ID27"
xxforms:cols="107" xxforms:rows="3">
<xf:label>
<span/>
</xf:label>
</xf:textarea>

and namespace:

 <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">

And attributes with xxforms:size xxforms:cols or xxforms:rows are not parsed, so fields havent proper size.
How to do it right way?
Currently i have removed "xxforms" namespaces so in textarea case it works like a charm, but for input[type=text] attribue "size" was removed by JavaScript. There are lines

var max = type.getMaxLength();
if (max) {
   input.maxLength = max;
} else {
   input.removeAttribute("maxLength");
}

var length = type.getDisplayLength();
if (length) {
   input.size = length;
} else {
   input.removeAttribute("size");
}

Why do you remove that attributes? Why not only set size/maxlength when necessary?

Greetings

Events not getting raised on subform element?

Hello,

I have a form sketch where subforms are embedded into the main form. However, there are complications:

  1. if subform failed to be found, then the user should be notified about the error
  2. user has to be able to dismiss the subform either by accepting or rejecting it

Here's the main form (showform3_load.xml):

<?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>Main Form</title>
    <xforms:model>
      <xforms:instance>
        <data xmlns=""/>
      </xforms:instance>
      <!-- FIXME: these actions are only run once (probably get removed on subform unload?) -->
      <xforms:action ev:event="xforms-link-exception" ev:observer="subform">
        <xforms:message>
          Failed to obtain the subform at: <xforms:output value="event('resource-uri')"/>,
          error code: <xforms:output value="event('response-status-code')"/>,
          error reason: <xforms:output value="event('response-reason-phrase')"/>
        </xforms:message>
      </xforms:action>
      <xforms:action ev:event="xforms-load-done" ev:observer="subform">
        <xforms:message>Load Success!</xforms:message>
        <xforms:toggle case="form-sub"/>
      </xforms:action>
    </xforms:model>
  </head>
  <body>
    <xforms:switch id="form-switch">
      <!-- this is the "main" form -->
      <xforms:case id="form-main">
        <h2>Main form</h2>
        <xforms:trigger>
          <xforms:label>Open subform 1</xforms:label>
          <xforms:action ev:event="DOMActivate">
            <xforms:message>Opening subform 1</xforms:message>
            <xforms:load show="embed" targetid="subform" resource="showform3_subform1.xml"/>
          </xforms:action>
        </xforms:trigger>
        <xforms:trigger>
          <xforms:label>Open subform 2</xforms:label>
          <xforms:action ev:event="DOMActivate">
            <xforms:message>Opening subform 2</xforms:message>
            <xforms:load show="embed" targetid="subform" resource="showform3_subform2.xml"/>
          </xforms:action>
        </xforms:trigger>
      </xforms:case>
      <!-- this is the portion of the form that we will be using for subforms (e.g. Edit subform) -->
      <xforms:case id="form-sub">
        <xforms:trigger>
          <xforms:label>Accept Subform</xforms:label>
          <xforms:action ev:event="DOMActivate">
            <xforms:message>Accepting Subform</xforms:message>
            <xforms:unload targetid="subform"/>
            <xforms:toggle case="form-main"/>
          </xforms:action>
        </xforms:trigger>
        <!-- this actually does what we want, but the subform *by itself*
           is invalid (there is no such targetid in the subform!
        -->
        <xforms:trigger>
          <xforms:label>Reject Subform</xforms:label>
          <xforms:action ev:event="DOMActivate">
            <xforms:message>Rejecting Subform</xforms:message>
            <xforms:unload targetid="subform"/>
            <xforms:toggle case="form-main"/>
          </xforms:action>
        </xforms:trigger>
        <xforms:group id="subform"/>
      </xforms:case>
    </xforms:switch>
  </body>
</html>

Here is subform 1 (showform3_subform1.xml):

<?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>Subform 1</title>
    <xforms:model>
      <xforms:instance>
        <data xmlns=""/>
      </xforms:instance>
    </xforms:model>
  </head>
  <body>
    <h2>Subform 1</h2>
    <p>hello world!</p>
  </body>
</html>

And finally, here is subform 3 (showform3_subform2.xml):

<?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>Subform 2</title>
    <xforms:model>
      <xforms:instance>
        <data xmlns=""/>
      </xforms:instance>
    </xforms:model>
  </head>
  <body>
    <h2>Subform 2</h2>
    <p>goodbye world!</p>
  </body>
</html>

To reproduce:

  1. Open the main form
  2. Click on "Open subform 1"
  3. Subform 1 will be opened
  4. Click on "Accept Subform"
  5. You will be brought back to the main form
  6. Click on either "Open subform 1" or "Open subform 2", and there is no change

Please help me figure this one out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.