The moose likes JSF and the fly likes XML schema into jsf datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "XML schema into jsf datatable" Watch "XML schema into jsf datatable" New topic

XML schema into jsf datatable

Amrita SeungJo

Joined: Apr 09, 2014
Posts: 4
I have an xml schema.. I need to display it as JSF datatable can anybody help me..

This is my xml schema


<?xml version="1.0" encoding="UTF-8"?>

<shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<orderperson>John Smith</orderperson>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<title>Hide your heart</title>

<name>John Maxwell</name>
<address>400 street</address>
<note>Special Edition</note>


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="stringtype">
<xs:restriction base="xs:string" />

<xs:simpleType name="inttype">
<xs:restriction base="xs:positiveInteger" />

<xs:simpleType name="dectype">
<xs:restriction base="xs:decimal" />

<xs:simpleType name="orderidtype">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{6}" />

<xs:complexType name="shiptotype">
<xs:element name="name" type="stringtype" />
<xs:element name="address" type="stringtype" />
<xs:element name="city" type="stringtype" />
<xs:element name="country" type="stringtype" />

<xs:complexType name="itemtype">
<xs:element name="title" type="stringtype" />
<xs:element name="note" type="stringtype" minOccurs="0" />
<xs:element name="quantity" type="inttype" />
<xs:element name="price" type="dectype" />

<xs:complexType name="shipordertype">
<xs:element name="orderperson" type="stringtype" />
<xs:element name="shipto" type="shiptotype" />
<xs:element name="item" maxOccurs="unbounded" type="itemtype" />
<xs:attribute name="orderid" type="orderidtype" use="required" />

<xs:element name="shiporder" type="shipordertype" />


Please reply soon as i need to submit it today for my college project :( :(
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

Actually, your "XML Schema" is the XSD file. The file you're calling the XML schema is simply XML data. The schema is the data structure definition.

To represent this XML data in a datatable, you need to convert it into something that a JSF DataModel object can wrap - in other words, an ordered collection of row objects such as a List or array.

One popular way to do this with XML is to use the Apache Digester, which can read XML and emit an object tree based on the rules that you provided the Digester with.

There are lots of other ways of doing this as well, such as JAXB.

Customer surveys are for companies who didn't pay proper attention to begin with.
jQuery in Action, 2nd edition
subject: XML schema into jsf datatable
Similar Threads
Problem in XSD
Help me for xsd creation
XML schema validation program error
Axis 1.4 throwing org.xml.sax.SAXException: Invalid element
Can someone verify the attached XML schema