Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Thanked 0 Times in 0 Posts

    Javascript xsd parser / execution engine?

    Say that I've got the following XML

    <block key="block1">
    <p>This is a <bold>paragraph</bold></p>
    <block key="block2">
    <p>Additional paragraph</p>

    Obviously the schematics of this data and the constraints placed upon them can be described using XSD. For example, the following rules would apply:

    * must be a document element as the top-level parent element
    * must be at least one block element as a child of document
    * each block must have a unique key value
    * blocks can have 1...n p child elements.
    * p elements can have 0...n bold child elements

    What I'm looking for is an engine that executes on the client-side (JavaScript / jQuery) that can parse the XSD and flag any errors. In addition I would also need to be able to interrogate the engine in order to determine what are valid child nodes at a particular level of the XML. For example, the following types of queries might be asked of the engine:

    * Q: Is the overall XML valid? A: yes / no + report
    * Q: I'm looking at the element block (key="block2"). What are the valid child elements of this element? A: p (1...n).
    * Q: I'm looking at the element p in the first block (key="block1"). What are the valid child elements of this element? A: #text, bold (0...n).

    Determining the valid child elements of a particular element is something akin to how Visual Studio e.g. 2010 uses Intellisense. For example, given a schema Visual Studio let's you know what the valid elements are at a particular position as you type enter the XML.

    Finally I've mentioned XSD / XML above but we do not necessarily have to be constrained to these technologies so alternative ideas will be appreciated equally as well.

    Thank you for taking the time to examine my post.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Thanked 619 Times in 599 Posts
    i haven't seen anything like that, but you can make your own using the xml dom exposed by an ajax request.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com


    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts