Smart way to admit optional items in url path.

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

Smart way to admit optional items in url path.

richhl
I do not know well regexp. Want to include info in the url arrivng the page-flow and want to make optional part of this information. Ive done this like this:

       <page id="escala" path-info="/neuro/([^/]+)" matcher="oxf:perl5-matcher"  default-submission="parametros.xml" model="general/cargar_cuestionarios.xpl" view="${1}/vista_escala.xhtml">
            <setvalue ref="/parametros/id_escala" matcher-group="1"/>
        </page>

        <page id="escalayexpediente" path-info="/neuro/([^/]+)/([^/]+)" matcher="oxf:perl5-matcher"  default-submission="parametros.xml" model="general/cargar_cuestionarios.xpl" view="${1}/vista_escala.xhtml">
            <setvalue ref="/parametros/id_escala" matcher-group="1"/>
            <setvalue ref="/parametros/id_expediente" matcher-group="2"/>
        </page>

        <page id="escalaexpedientefecha" path-info="/neuro/([^/]+)/([^/]+)/([^/]+)" matcher="oxf:perl5-matcher"  default-submission="parametros.xml" model="general/cargar_cuestionarios.xpl" view="${1}/vista_escala.xhtml">
            <setvalue ref="/parametros/id_escala" matcher-group="1"/>
            <setvalue ref="/parametros/id_expediente" matcher-group="2"/>
            <setvalue ref="/parametros/fecha" matcher-group="3"/>
        </page>

Is there a clever and elegant way to doy it in one declaration?

thx
 


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Smart way to admit optional items in url path.

Alessandro Vernet
Administrator
Richard,

On Oct 7, 2008, at 3:18 AM, Richard C. Hidalgo Lorite wrote:

>        <page id="escalaexpedientefecha" path-info="/neuro/([^/]+)/
> ([^/]+)/([^/]+)" matcher="oxf:perl5-matcher"  default-
> submission="parametros.xml" model="general/cargar_cuestionarios.xpl"  
> view="${1}/vista_escala.xhtml">
>            <setvalue ref="/parametros/id_escala" matcher-group="1"/>
>            <setvalue ref="/parametros/id_expediente" matcher-
> group="2"/>
>            <setvalue ref="/parametros/fecha" matcher-group="3"/>
>        </page>


I think you could keep just the 3rd one, using the following regexp  
(added some question marks after the part of the URI which might be  
"missing"):

/neuro/([^/]+)/?([^/]+)?/?([^/]+)?

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet



--
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
OW2 mailing lists service home page: http://www.ow2.org/wws