Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

XSD Parser, XML Parsers doesn't work because XSD can be written different ways

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to find the root Type of the XSD ( You know the root node of the corresponding XML, But I don't have it's XML, just XSD)
I need to identify the root type, The normal XML ( XSD also a type of XML) doesn't work simply because you can write same XSD in different ways.
http://www.w3schools.com/schema/schema_example.asp


I tried XSOM, Apache XMLBeans ( There is a bug in programatically loading the xsd in it) and http://ws.apache.org/commons/xmlschema20/
But, nothing seems to work for above.

It is not that it cannot be done, But I don't want to reinvent this wheel.
Any help would be highly appreciated.

 
Greenhorn
Posts: 17
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been looking at a few of mine, and I think if you only have the XSD you may have to go back to basics -- the root tag has no REQUIRED identifying mark -- it is the only element tag that is neither a simple element nor contained within another complex element.

So use old-fashioned W3C DOM and parse your XSD as normal XML, then walk the tree and build a Map of all the element names, then walk the tree again and delete from the map:

-- all simple elements
-- all elements that occur inside another element.

You should be left with one element in your Map ...
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic