Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:46:51+00:00 2026-05-16T05:46:51+00:00

I have been working on a project for a month or so now to

  • 0

I have been working on a project for a month or so now to develop a XML validator (XSD) in javascript. I have gotten really close but keep running into problems.

The only thing I have working well is normalizing schema structures into FSA that I store in the DOM. I have tried several methods to validate my xml structures against the FSA and come short each time.

The validator is being used to run a client side WYSIWYG XML editor so it has to meet the following requirements

  • Must be efficient ( < 15ms to validate an element child node pattern even with complex models)
  • Must expose a Post Validation Schema Infoset (PSVI) which can be queried to determine what elements can be inserted/removed from the document at various points and still keep the document valid.
  • Must be able to validate a xml child node structure and if invalid return what content was EXPECTED or what content is UNEXPECTED.

— More info Consider the following example–
First I convert schema structures to a general FSA representation normalizing out things like xs:group and xs:import with respect to namespaces. For instance consider:

<xs:group name="group1">
    <xs:choice minOccurs="2">
         <xs:element name="e2" maxOccurs="3"/>
         <xs:element name="e3"/>
    </xs:choice>
</xs:group>
<xs:complexType>
    <xs:seqence>
        <xs:element name="e1"/>
        <xs:group ref="group1"/>
    </xs:sequence>
<xs:complexType>

Would be converted into a similar generalized structure:

<seq>
    <e name="e" minOccurs="2"/>
    <choice minOccurs="2">
         <e name="e2" maxOccurs="3"/>
         <e name="e3"/>
    </choice>
</seq>

I do this all server side through XQuery and XSLT.

My first attempt at building a validator was with recursive functions in javascript. Along the way if I found content that could exist I would add it to a global PSVI signaling that it could be added at a specified point in the hierarchy.

My second attempt was iterative, and was much faster but both of these suffered from the same problem.

Both of these could correctly validate simple content models, but as soon as the models became more complex and very nested they failed.

I am thinking that I am approaching this problem from the completely wrong direction. From what I have read most FSA’s are processed by pushing states to a stack, but I am not sure how to do this in my situation.

I need advice on the following questions:

  1. Is a state machine the right solution here, will it acomplish the goals stated at the top.?
  2. If using a state machine whats the best method to convert the schema structure to DFA? Thompson algorithm? Do I need to optimize the DFA for this to work.
  3. Whats the best way (or most efficient way) to implement this all in javascript (Note optimizations, and pre-processing can be done on the server)

Thanks,

Casey

Additional Edits:

I have been looking at the tutorial here: http://www.codeproject.com/KB/recipes/OwnRegExpressionsParser.aspx focused on regular expressions. It seems to be very similar to what I need but focused on building a parser for regex. This brings up some interesting thoughts.

I am thinking that xml schema breaks down into only a few operators:

sequence -> Concatination
choice -> Union
minOccurs/maxOccurs – Probably need more than Kleene Closure, not totally sure the best way to represent this operator.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:46:51+00:00Added an answer on May 16, 2026 at 5:46 am

    When I was going through the same learning process I found that I needed to spend some time studying books on compiler-writing (for example Aho & Ullman). The construction of a finite state machine to implement a grammar is standard textbook stuff; it’s not easy or intuitive, but it is thoroughly described in the literature – except perhaps for numeric minOccurs/maxOccurs, which don’t occur in typical BNF language grammars, but are well covered by Thompson and Tobin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with Struts for some time, but for a project I
I have been working on the project where application is using grails 1.2.2.... Now
I have been working on a project which uses Grails with Hibernate... Now the
I project I have been working on has now been split between me and
I have been working on a project that has 2 interfaces - windows forms
I have been working on a Java project for a class for a while
I have been working on a web services related project for about the last
I have a project that I have been working on for a while, just
On a recent project I have been working on in C#/ASP.NET I have some
I am about to start a web project and have been working almost exclusively

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.