• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Can I specify in XSD for not accepting a particular pattern

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am validating my XML file by means of an XSD. Can I specify in
the XSD for not accepting a particular pattern.
I don't want to accept the string containing pattern "'".
Becuase if it tries to get inserted into database error will occur.
Thanks in advance
prathibha
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
I think, if you derive your type from xsd:string and then you specify what it should contain in the xsd attern you'll get what what you're looking for.
For example if I wanted my string to contain things like
<string of lower letters>@<string of lower letters>.com
(as in ambrosetati@home.com), I could do something like this:
<xsd:element name="myUrl">
<xsd:simpleType>
<xsd:restriction base = "xsd:string">
<xsd attern value = "([a-z])+@([a-z])+.(com)"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

if you change <xsd attern value = "([a-z])+@([a-z])+.(com)"/> to
<xsd attern value = "([a-z])+"/> you'll ensure that it will not be empty and will only contain any combination of letters.
Hope this helps
Ambrose Tati

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!