Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XSD Validation - Allowed characters

XSD Validation - Allowed characters

Scheduled Pinned Locked Moved XML / XSL
regexhelpcsharpdatabasecloud
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erik Westermann
    wrote on last edited by
    #1

    I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help... I have a set of allowed characters that I could describe using this regular expression:

    [\w?\-?.?\s?\'?,?#?-[_]]

    This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores. The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:

    xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"

    This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present. I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this: [^\w?\-?.?\s?\'?,?#?] ), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass! The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters. Any advice?

    Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
    SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
    wWorkflow.net or +1 416-809-1453

    E 1 Reply Last reply
    0
    • E Erik Westermann

      I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help... I have a set of allowed characters that I could describe using this regular expression:

      [\w?\-?.?\s?\'?,?#?-[_]]

      This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores. The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:

      xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"

      This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present. I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this: [^\w?\-?.?\s?\'?,?#?] ), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass! The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters. Any advice?

      Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
      SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
      wWorkflow.net or +1 416-809-1453

      E Offline
      E Offline
      Erik Westermann
      wrote on last edited by
      #2

      Well, in case anyone is interested, I solved my problem. Schema validation turned out to be too limited to handle all cases, so now I use schema validation combined with rules in the BizTalk Rules Engine (this was part of a larger BizTalk-based solution). So, schema validation catches more obvious, structural issues whereas the Business Rules make it easier to validate based on regular expressions, etc.

      Erik Westermann - wWorkflow.net - BizTalk Consulting Services
      SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
      wWorkflow.net or +1 416-809-1453

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups