schema validation

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

schema validation

c.harder
Hi again,
I tried to rebuilding the tutorial/hello4 example, so that I can use xml schema for validation. Problem: Trigger is not working.

At first I tried to use xform-binds for validation. That was working fine, but not at all. I tried to use "required" attribute in bind "first-name". Its working, but theres no hint or highlighted mark for input when I try to submit an empty input. Maybe I can do the same with "constraint" attribute instead of "required". Please can you give an example for bind which is doing that?

I think its a good thing, if you could give an easier example for schema use as shown in BizDoc.

If there is no way for that, please tell me how to use schema for validation. I think this is the better solution, cause of survey of codes.

thanks
Clemens

Heres the changed source code:
form-schema.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="myform">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="action" type="xs:string" />
        <xs:element name="first-name" type="requiredNonEmptyString" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="requiredNonEmptyString">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:whiteSpace value="collapse" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

ask-name-view.xhtml
<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" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <head>
    <title>Hello World Page Flow</title>
    <xforms:model schema="oxf:/examples/tutorial/hello4/form-schema.xsd">
      <xforms:instance id="main-instance">
        <xi:include href="input:instance" />
      </xforms:instance>
      <xforms:submission id="main" ref="/" method="post" action="/tutorial-hello4" />
    </xforms:model>
  </head>
  <body>
    <p>
      Please enter your first name:
      <xforms:input ref="first-name">
        <xforms:label />
      </xforms:input>
      <xforms:trigger>
        <xforms:label>Greet Me!</xforms:label>
        <xforms:action ev:event="DOMActivate">
          <xforms:setvalue ref="action">next</xforms:setvalue>
          <xforms:send submission="main" />
        </xforms:action>
      </xforms:trigger>
    </p>
  </body>
</html>

page-flow.xml
<config xmlns="http://www.orbeon.com/oxf/controller" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xu="http://www.xmldb.org/xupdate" xmlns:oxf="http://www.orbeon.com/oxf/processors">

  <page id="ask-name" path-info="/tutorial-hello4" default-submission="initial-instance.xml" view="ask-name-view.xhtml">
    <action when="/myform/action = 'next'">
      <result page="display-name" transform="oxf:xslt">
        <myform xmlns="" xsl:version="2.0">
          <xsl:copy-of select="doc('input:instance')/myform/*" />
        </myform>
      </result>
    </action>
  </page>

  <page id="display-name" path-info="/tutorial-hello4/display-name" view="display-name-view.xhtml">
    <action when="/myform/action = 'back'">
      <result page="ask-name" transform="oxf:xslt">
        <myform xmlns="" xsl:version="2.0">
          <xsl:copy-of select="doc('input:instance')/myform/*" />
        </myform>
      </result>
    </action>
  </page>

  <epilogue url="oxf:/config/epilogue.xpl" />

</config>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: schema validation

c.harder
Hi,
I've found a page (http://www.w3schools.com/xpath/xpath_functions.asp) where all xpath function are listed. There's what I need for solving my problem with bindings. (constraint="string-length(.)>0"). That replaces the need of "required" attribute for my example, but does not explain the behavior of "required", when trieing tu submit an empty input (no error mark).
Also I would still be very happy, if I could see an example with schema.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: schema validation

Alexander Žaťko
What version of OPS and which XForms engine (classic or NG) are you
using? I posted similar questions in the past to this list to the one
you did. Please check the archive - maybe that will help you.

A.

On Nov 29, 2005, at 7:12 AM, [hidden email] wrote:

> Hi,
> I've found a page (http://www.w3schools.com/xpath/xpath_functions.asp)
> where all xpath function are listed. There's what I need for solving
> my problem with bindings. (constraint="string-length(.)>0"). That
> replaces the need of "required" attribute for my example, but does not
> explain the behavior of "required", when trieing tu submit an empty
> input (no error mark).
> Also I would still be very happy, if I could see an example with
> schema.
>
>
> --
> You receive this message as a subscriber of the
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: schema validation

c.harder
Hi Alexander,
sorry but I cant find your thread. Can you post the title?

I'm using xforms ng on orbeon 3 beta 3, cvs snapshot of yesterday.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: schema validation

Alexander Žaťko
Well, the list thread I mentioned relates to the classic XForms engine,
so I am not sure if it will be of any help to you. The subject was
"trouble using classic xforms with ops beta 3"

A.


On Nov 29, 2005, at 9:17 AM, [hidden email] wrote:

> Hi Alexander,
> sorry but I cant find your thread. Can you post the title?
>
> I'm using xforms ng on orbeon 3 beta 3, cvs snapshot of yesterday.
>
>
> --
> You receive this message as a subscriber of the
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: schema validation

c.harder
Thanks for that hint Alexander. I've red it and yes, I think its the same problem. But it's not so bad, cause of "constraint" attribute.

Now there is only left an example for schema use ;-) please



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: schema validation

Erik Bruchez
Administrator
In reply to this post by c.harder
[hidden email] wrote:

 > I tried to rebuilding the tutorial/hello4 example, so that I can use
 > xml schema for validation. Problem: Trigger is not working.
 >
 > At first I tried to use xform-binds for validation.

Good, that should work.

 > That was working fine, but not at all.

Uh? ;-)

 > I tried to use "required" attribute in bind "first-name". Its
 > working, but theres no hint or highlighted mark for input when I try
 > to submit an empty input.

"Required-but-empty" fields are supposed to be correctly highlighted
now.

 > Maybe I can do the same with "constraint" attribute instead of
 > "required". Please can you give an example for bind which is doing
 > that?

The XForms Controls example shows exactly this, for example:

<xforms:bind nodeset="age" constraint="number(.) >= 0 and number(.)
&lt;= 150"/>

 > I think its a good thing, if you could give an easier example for
 > schema use as shown in BizDoc.

 > If there is no way for that, please tell me how to use schema for
 > validation. I think this is the better solution, cause of survey of
 > codes.

Ok, there is a trick when you use XInclude, which is that XInclude
always add an xml:base attribute on the root element of the included
document. Often, this is annoying, but the XInclude spec is quite
clear on the subject.

This means that you want your schema to allow for an xml:base
attribute on your root element. I have not found a way of doing this
with one file, so here is a solution with two files:

form-schema.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">

     <xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml-base.xsd"/>

     <xs:element name="myform">
         <xs:complexType>
             <xs:sequence>
                 <xs:element name="action" type="xs:string"/>
                 <xs:element name="first-name"
type="requiredNonEmptyString"/>
             </xs:sequence>
             <xs:attributeGroup ref="xml:base"/>
         </xs:complexType>
     </xs:element>

     <xs:simpleType name="requiredNonEmptyString">
         <xs:restriction base="xs:string">
             <xs:minLength value="1"/>
             <xs:whiteSpace value="collapse"/>
         </xs:restriction>
     </xs:simpleType>

</xs:schema>

xml-base.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified" attributeFormDefault="qualified"
            targetNamespace="http://www.w3.org/XML/1998/namespace">

     <xs:attributeGroup name="base">
         <xs:attribute name="base" type="xs:anyURI" use="optional"/>
     </xs:attributeGroup>

</xs:schema>

With this, referring to form-schema.xsd from your XForms model, as you
do now, will work.

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws