Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript xsd parser / execution engine?

    Say that I've got the following XML

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

    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
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 583 Times in 564 Posts
    i haven't seen anything like that, but you can make your own using the xml dom exposed by an ajax request.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    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
    •