This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes converting xsd to html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "converting xsd to html" Watch "converting xsd to html" New topic
Author

converting xsd to html

Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
Hi

Can anyone help me how to convert xsd to html page, i am new to xsd,if possible sample code please.......


Thanks in advance

Prathyusha
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Welcome to javaranch Prathyusha. Before we can answer this question can you tell us why you are trying to convert a XSD document, which is a rule set for XMLs, to HTML ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
Hi
I have an xsd file i need to read the xsd and the values need to be populated in an html page..could you please tell methe ways to parse an xsd and reading the content in it..

Or any other way to convert an xsd to html page
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You can parse the XSD using a SAX / StaX parser and display it in a JSP page. Or, you can write a XSLT and apply that to the XSD, which can create a HTML page. The answer depends on the level of flexibility you desire and the requirement.
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
I analyzed in the following way
1) At first, I tried to convert xsd file to html using xslt.
But xslt is taking xsl or xml documents as an input but not the xsd files.
I got in one link the converted html code but I couldn’t found the source code
I tried using a java file having a method with 3 arguments which takes input of a xml, xsl and output as a html file
2) Again I tried to convert xsd to xsl and again to xhtml but it was also not possible.
3) Again I tried to read the xsd file and parse it to populate in the html.
I was not able to parse it because as it was an xsd ,I got suggestions to use JAXB and XSOM parser to parse it.
I was able to parse a xml file but not the xsd using the DOM parser.

Please provide me your suggestions regarding this issue.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

An XSD file is an XML file so little of what you are saying makes sense.

Why are you doing this in the first place? It seems non-sensical at many levels. Perhaps posting your motivation will help us understand what you are really trying to accomplish.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
could you provide me any sample code please..
my sample xsd is as follows
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="maps">
<xs:complexType>
<xs:sequence>
<xs:element ref="class" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="class">
<xs:complexType>
<xs:sequence>
<xs:element ref="field" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="key" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="stdlabels" minOccurs="0"/>
<xs:element ref="triggers" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="classattributes"/>
</xs:complexType>
</xs:element>
<xs:element name="field">
<xs:complexType>
<xs:sequence>
<xs:element ref="label" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="fieldattributes"/>
</xs:complexType>
</xs:element>
<xs:element name="key">
<xs:complexType>
<xs:sequence>
<xs:element ref="keyfield" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="keyattributes"/>
</xs:complexType>
</xs:element>
<xs:element name="keyfield">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="triggers">
<xs:complexType>
<xs:sequence>
<xs:element ref="trigger" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="trigger">
<xs:annotation>
<xs:documentation>Trigger listeners for this Class</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="label">
<xs:complexType>
<xs:attribute name="value" type="xs:string" use="optional"/>
<xs:attribute name="locale" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="stdlabels">
<xs:complexType>
<xs:sequence>
<xs:element ref="stdlabel" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="stdlabel">
<xs:annotation>
<xs:documentation>The Standard Label override</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="labels" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="stdlabelattributes"/>
</xs:complexType>
</xs:element>
<xs:element name="labels">
<xs:complexType>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>value of the label in the given locale</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="locale" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>value of the locale</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<!-- BEGIN STDLABEL ATTRIBUTES -->
<xs:attributeGroup name="stdlabelattributes">
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>Name of the field or attribute</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" use="required">
<xs:annotation>
<xs:documentation>Default English value of the Label</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
What is the actual purpose of xsd other than validating an xml???
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Prathyusha Reddy wrote:What is the actual purpose of xsd other than validating an xml???


It has no other purpose. I am still not sure why you would want to convert the XSD to a HTML. There is no meaningful user data that you can publish, unless this tool is for developers or someone that understands XSD internals.

A plain vanilla XSLT with HTML output and a few elements can give what you want
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
Thanks for your reply, i have a doubt..will the xslt take the input as xsd?? As of my knowledge i think only it takes the xsl and xml right..
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

A XSD is a XML. Yes it can take XSD as an input
Prathyusha Reddy
Ranch Hand

Joined: Jan 20, 2010
Posts: 31
Thanks for your reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: converting xsd to html
 
Similar Threads
how can i create java classes from given wsdl
Loading Properties file into a list
JAXB: Two xsd - Create single JAXBContext
XSD for HTML elements
compare xml files with ant or maven