This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes validation.xml-problem including Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation.xml-problem including "&" in one of the constants " Watch "validation.xml-problem including "&" in one of the constants " New topic
Author

validation.xml-problem including "&" in one of the constants

cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
How can I modify my constant in validation.xml(for validator framework) so that it allows a user to include & along with alphabets , single apostrophe(which is already in there)?
<constant>
<constant-name>somename</constant-name>
<constant-value>^([a-zA-Z]|'|)*$</constant-value>
</constant>
At this point it just lets me add alphabets(be it small or capital) and have a single apostrophe .
This is done so as to allow names like
AB
Macy's
I am facing problem when i try to include &(special character) so as to allow names like
A&B



Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you want an "&" character in an XML text node, you have to escape it as "&amp;". Or you can make the entire text node a CDATA node. This tutorial page gives examples of both techniques.
[ May 04, 2006: Message edited by: Paul Clapham ]
cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
Thanks... will go through the link and try it out.
cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
Thanks Paul..... "&" worked for the valiation.xml
cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
er......meant &
cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
"&"
cj jaswal
Greenhorn

Joined: Jan 19, 2006
Posts: 7
i give up ...............it's ampersand which worked( getting it to show up on the post is as difficult as trying out modifying my validation.xml if not more)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validation.xml-problem including "&" in one of the constants
 
Similar Threads
Validating an Amount Field
Validwhen validator question
validation.xml file
problem in Struts Declerative validations
Struts validator-rules.xml regex problem