Flexible XSchema validation


XML & Web services: Flexible XSchema validation

  1. Flexible XSchema validation (1 messages)

    I have a question regarding the appropriate use of XSchema validation - I would like to use XSchema to validate XML feeds that we receive. I am interested in designing a flexible XSchema validation, where I can validate the elements I am interested in and ignore any other additions on extensions. To be specific, I would like to validate all top level elements in the XML file, and ensure that there is a single instance of , , elements under . I do not care about additional elements under customer, and want to ignore any other elements, attributes, PIs etc in the XML. I looked into XSchema and it seems to be a fit only for very rigid validations. Any comments?
  2. Try custom validation[ Go to top ]

    You are right that you are trying to do something that isn't one of the things that W3C XML Schema is best at. There are a few options you could try, depending on what is politically and technically acceptable for your project: * you could try an alternative schema language. Schematron can certainly do what you want, and I suspect RELAX NG could as well; * you could write a custom validator. For example, for this problem, you only need to check the child elements of . That's fairly easy to write a custom/bespoke validator for, using SAX or StAX. You could also write an XPath based validator (which would work a bit like Schematron). Cheers, Tony. -- Anthony B. Coates Author, XML APIs Chapter Advanced XML Applications from the Experts at The XML Guild http://www.amazon.com/Advanced-XML-Applications-Experts-Guild/dp/1598632140/ref=sr_1_1/002-6329699-8173628?ie=UTF8&s=books&qid=1178178311&sr=1-1