0

I want to display an XML schema in the form of a tree which I should be able to expand, collapse and drag-n-drop on to external droppable. For example :

            <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
              <xs:element name="catalog">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="cd">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="title" type="xs:string"/>
                          <xs:element name="artist" type="xs:string"/>
                          <xs:element name="country" type="xs:string"/>
                          <xs:element name="company" type="xs:string"/>
                          <xs:element name="price" type="xs:float"/>
                          <xs:element name="year" type="xs:short"/>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:schema>

I need to display treenodes as :

-catalog
 -cd
   title(string)
   artist(string)
   .
   .
   .
   year(short)

All that are marked with "-" are expandable and collapsible and contain the child elements. How do I achieve this in javascript/jquery? Are there any plugins in jquery related to this?

Thank you all.

Ravz
  • 43
  • 7

1 Answers1

0

Not sure if you are still after an answer for this but I recently took up a similar task. This might not be the most efficient way of achieving what you want but here are the steps that I took to achieve the above.

  1. Create a sample xml file from the xsd schema. Oxygen XML editor has functionality to do this.
  2. Run the sample xml file against an xslt to generate every individual xpath in the schema.
  3. Parse the xpaths into java objects and convert into JSON format.

Here are some links that may help you with the task...

Best way to represent list of XPaths in java

How to get xpaths for all leaf elements from XML?

Let me know if you need any other help!

Community
  • 1
  • 1
Brendon S
  • 55
  • 7