CINXE.COM
XMLBeans Samples
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta content="Apache Forrest" name="Generator"> <meta name="Forrest-version" content="0.9"> <meta name="Forrest-skin-name" content="pelt"> <title>XMLBeans Samples</title> <link type="text/css" href="../skin/basic.css" rel="stylesheet"> <link media="screen" type="text/css" href="../skin/screen.css" rel="stylesheet"> <link media="print" type="text/css" href="../skin/print.css" rel="stylesheet"> <link type="text/css" href="../skin/profile.css" rel="stylesheet"> <script src="../skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="../skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="../skin/fontsize.js" language="javascript" type="text/javascript"></script> <link rel="shortcut icon" href="../images/favicon.ico"> </head> <body onload="init()"> <script type="text/javascript">ndeSetTextSize();</script> <div id="top"> <!--+ |breadtrail +--> <div class="breadtrail"> <a href="https://www.apache.org/">The Apache Software Foundation</a> > <a href="https://xmlbeans.apache.org">Apache XMLBeans</a><script src="../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script> </div> <!--+ |header +--> <div class="header"> <!--+ |start group logo +--> <div class="grouplogo"> <a href="https://www.apache.org/"><img class="logoImage" alt="The Apache Software Foundation" src="../images/group-logo.png" title="THE APACHE SOFTWARE FOUNDATION provides support for the Apache Community of Open Source software projects, which provide software products for the public good. "></a> </div> <!--+ |end group logo +--> <!--+ |start Project Logo +--> <div class="projectlogo"> <a href="https://xmlbeans.apache.org"><img class="logoImage" alt="Apache XMLBeans" src="../images/project-logo.png" title="XMLBeans is a tool that allows access to the full power of XML in a Java friendly way. The idea is to take advantage of the richness and features of XML and XML Schema and have these features mapped as naturally as possible to the equivalent Java language and typing constructs. "></a> </div> <!--+ |end Project Logo +--> <!--+ |start Search +--> <div class="searchbox"> <form action="https://www.google.com/search" method="get" class="roundtopsmall"> <input value="xmlbeans.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google"> <input name="Search" value="Search" type="submit"> </form> </div> <!--+ |end search +--> <!--+ |start Tabs +--> <ul id="tabs"> <li> <a class="unselected" href="../index.html">Home</a> </li> <li> <a class="unselected" href="../download/index.html">Download</a> </li> <li> <a class="unselected" href="../documentation/index.html">Documentation</a> </li> <li class="current"> <a class="selected" href="../samples/index.html">Samples</a> </li> <li> <a class="unselected" href="../community/index.html">Community</a> </li> <li> <a class="unselected" href="../resources/index.html">Resources</a> </li> </ul> <!--+ |end Tabs +--> </div> </div> <div id="main"> <div id="publishedStrip"> <!--+ |start Subtabs +--> <div id="level2tabs"></div> <!--+ |end Endtabs +--> <script type="text/javascript"><!-- document.write("Last Published: " + document.lastModified); // --></script> </div> <!--+ |breadtrail +--> <div class="breadtrail"> </div> <!--+ |start Menu, mainarea +--> <!--+ |start Menu +--> <div id="menu"> <div onclick="SwitchMenu('menu_selected_1.1', '../skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Samples</div> <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;"> <div class="menupage"> <div class="menupagetitle">Getting the Samples</div> </div> <div onclick="SwitchMenu('menu_1.1.2', '../skin/')" id="menu_1.1.2Title" class="menutitle">Samples List</div> <div id="menu_1.1.2" class="menuitemgroup"> <div class="menuitem"> <a href="../samples/AbstractTypes.html">AbstractTypes</a> </div> <div class="menuitem"> <a href="../samples/Any.html">Any</a> </div> <div class="menuitem"> <a href="../samples/DateTime.html">DateTime</a> </div> <div class="menuitem"> <a href="../samples/MixedContent.html">MixedContent</a> </div> <div class="menuitem"> <a href="../samples/OrderMatters.html">OrderMatters</a> </div> <div class="menuitem"> <a href="../samples/SchemaEnum.html">SchemaEnum</a> </div> <div class="menuitem"> <a href="../samples/SubstitutionGroup.html">SubstitutionGroup</a> </div> <div class="menuitem"> <a href="../samples/Validation.html">Validation</a> </div> <div class="menuitem"> <a href="../samples/vxsdb.html">Velocity XmlBeans</a> </div> <div class="menuitem"> <a href="../samples/XmlTree.html">XmlTree</a> </div> <div class="menuitem"> <a href="../samples/XQueryXPath.html">XQueryXPath</a> </div> <div class="menuitem"> <a href="../samples/SampleTemplate.html">SampleTemplate</a> </div> </div> <div class="menuitem"> <a href="../samples/index.html#Examples+in+XMLBeans+Source">Examples in XMLBeans Source</a> </div> </div> <div id="credit"> <hr> <a href="https://www.apache.org/events/current-event.html"><img border="0" title="Apache Event" alt="Apache Event - logo" src="../https://www.apache.org/events/current-event-125x125.png" style="width: 125px;height: 125px;"></a> </div> <div id="roundbottom"> <img style="display: none" class="corner" height="15" width="15" alt="" src="../skin/images/rc-b-l-15-1body-2menu-3menu.png"></div> <!--+ |alternative credits +--> <div id="credit2"> <a href="https://donate.apache.org/"><img border="0" title="Support Apache" alt="Support Apache - logo" src="../images/support-asf.png" style="width: 125px;height: 125px;"></a><a href="https://www.apache.org/foundation/press/kit/#poweredby"><img border="0" title="powered by POI" alt="powered by POI - logo" src="../images/poweredby-xmlbeans-logo.png" style="width: 125px;height: 125px;"></a> </div> </div> <!--+ |end Menu +--> <!--+ |start content +--> <div id="content"> <h1>XMLBeans Samples</h1> <div id="front-matter"></div> <a name="Getting+the+Samples"></a> <h2 class="boxed">Getting the Samples</h2> <div class="section"> <p> Click the name of a sample listed below to go to a page that describes the sample in more detail. From there, you can view the files that make up the sample. This sample repository is just getting started, so be sure to check back for new additions. </p> <p> To get started with the samples, follow the instructions on the <a href="../documentation/conInstallGuide.html">Installing XMLBeans</a> page first. Then get the sample code in one of the following ways: </p> <ul> <li>download all samples (<a href="samples.zip">zip</a> <a href="samples.tgz">tgz</a>)</li> <li>download individual samples <a href="#Samples+List">below</a> </li> <li>all sample source is available in <a href="../download/index.html#Source+via+SVN+checkout">SVN</a> </li> </ul> <p> If you have a sample that you'd like to share, grab the <a href="SampleTemplate.html">sample template</a> and donate it to us. We'd be happy to post it! </p> </div> <a name="Samples+List"></a> <h2 class="boxed">Samples List</h2> <div class="section"> <table class="ForrestTable" cellspacing="1" cellpadding="4"> <tr> <th colspan="1" rowspan="1">Title</th> <th colspan="1" rowspan="1">Download</th> <th colspan="1" rowspan="1">Date Available</th> </tr> <tr> <td colspan="1" rowspan="1"> <strong>All samples</strong> <br> Get 'em all at once. </td> <td colspan="1" rowspan="1"> <a href="samples.zip">zip</a> <a href="samples.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-10-28</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="AbstractTypes.html"> <strong>AbstractTypes</strong> </a> <br> This sample illustrates the building and use of abstract XmlSchema types in XmlBeans. </td> <td colspan="1" rowspan="1"> <a href="AbstractTypes.zip">zip</a> <a href="AbstractTypes.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-02-07</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="Any.html"> <strong>Any</strong> </a> <br> Illustrates how you can use the XMLBeans API to work with XML based on schema that features xs:any particles </td> <td colspan="1" rowspan="1"> <a href="Any.zip">zip</a> <a href="Any.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-07-08</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="DateTime.html"> <strong>DateTime</strong> </a> <br> This sample demonstrates how you can work with XML Schema primitive types date, dateTime, time, duration, gDay. </td> <td colspan="1" rowspan="1"> <a href="DateTime.zip">zip</a> <a href="DateTime.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-10-28</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="MixedContent.html"> <strong>MixedContent</strong> </a> <br> Work with mixed content XML by combining strong types generated from schema with an <span class="codefrag">XmlCursor</span> instance. </td> <td colspan="1" rowspan="1"> <a href="MixedContent.zip">zip</a> <a href="MixedContent.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-09-15</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="OrderMatters.html"> <strong>OrderMatters</strong> </a> <br> This samples gives an quick overview of how to use XmlBeans with both the strongly typed XmlObjects (StatementDocument, Transaction) and with the XmlCursor. </td> <td colspan="1" rowspan="1"> <a href="OrderMatters.zip">zip</a> <a href="OrderMatters.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-10-28</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="SchemaEnum.html"> <strong>SchemaEnum</strong> </a> <br> Access XML values that are defined in schema as enumerations. </td> <td colspan="1" rowspan="1"> <a href="SchemaEnum.zip">zip</a> <a href="SchemaEnum.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-09-15</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="SubstitutionGroup.html"> <strong>SubstitutionGroup</strong> </a> <br> This sample illustrates substitution group elements in an XML document. </td> <td colspan="1" rowspan="1"> <a href="SubstitutionGroup.zip">zip</a> <a href="SubstitutionGroup.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-10-28</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="Validation.html"> <strong>Validation</strong> </a> <br> Illustrates how you can use the XMLBeans API to validate XML instances against schema. </td> <td colspan="1" rowspan="1"> <a href="Validation.zip">zip</a> <a href="Validation.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-07-08</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="vxsdb.html"> <strong>Velocity XmlBeans</strong> </a> <br> Vxsdb is a XmlBeans sample application which derives a Jakarta Commons SQL data model from an xml schema. </td> <td colspan="1" rowspan="1"> <a href="AbstractTypes.zip">zip</a> <a href="AbstractTypes.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-02-07</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="XmlTree.html"> <strong>XmlTree</strong> </a> <br> Illustrates how you can use the XMLBeans API to create a Java tree view of an XML document. </td> <td colspan="1" rowspan="1"> <a href="XmlTree.zip">zip</a> <a href="XmlTree.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-07-08</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="XQueryXPath.html"> <strong>XQueryXPath</strong> </a> <br> Illustrates how you can use the XMLBeans API to execute XPath and XQuery expressions. </td> <td colspan="1" rowspan="1"> <a href="XQueryXPath.zip">zip</a> <a href="XQueryXPath.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2005-07-08</td> </tr> <tr> <td colspan="1" rowspan="1"> <a href="SampleTemplate.html"> <strong>SampleTemplate</strong> </a> <br> A template for sample authors to get started. Please follow these conventions. </td> <td colspan="1" rowspan="1"> <a href="SampleTemplate.zip">zip</a> <a href="SampleTemplate.tgz">tgz</a> </td> <td colspan="1" rowspan="1">2004-09-15</td> </tr> </table> </div> <a name="Examples+in+XMLBeans+Source"></a> <h2 class="boxed">Examples in XMLBeans Source</h2> <div class="section"> <p> Also, some of the code in the XmlBeans tools is a very good example of how to use XmlBeans. In paricular, see: </p> <ul> <li> <span class="codefrag">org.apache.xmlbeans.impl.tool.InstanceValidator</span> It is an excellent example of how to load a schema type system dynamically at runtime, load and validate an instance within that type system, and how to obtain lists of and locations for validation errors.</li> <li> <span class="codefrag">org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil</span> It is a great example of how to combine the XmlCursor and SchemaType APIs to create a full [sub]document that includes required children, default values etc.</li> <li> <span class="codefrag">org.apache.xmlbeans.impl.tool.PrettyPrinter</span> It is a reasonable example of how to load and save out an arbitrary XML document. XmlOptions are used to produce the pretty-printing.</li> </ul> </div> </div> <!--+ |end content +--> <div class="clearboth"> </div> </div> <div id="footer"> <!--+ |start bottomstrip +--> <div class="lastmodified"> <script type="text/javascript"><!-- document.write("Last Published: " + document.lastModified); // --></script> </div> <div class="copyright"> Copyright © 2004-2024 <a href="https://www.apache.org/">The Apache Software Foundation</a> <br> Apache, Apache XMLBeans, Apache POI, the Apache feather logo, and the Apache XMLBeans logos are trademarks of The Apache Software Foundation. </div> <div id="logos"> <a href="https://validator.w3.org/check/referer"><img style="height: 31px; width: 88px;" title="Valid HTML 4.01!" alt="Valid HTML 4.01!" src="../skin/images/valid-html401.png" class="logoImage"></a><a href="https://jigsaw.w3.org/css-validator/check/referer"><img style="height: 31px; width: 88px;" title="Valid CSS!" alt="Valid CSS!" src="../skin/images/vcss.png" class="logoImage"></a> </div> <div id="feedback"> Send feedback about the website to: <a id="feedbackto" href="mailto:dev@poi.apache.org?subject=Feedback%C2%A0samples/index.html">dev@poi.apache.org</a> </div> <!--+ |end bottomstrip +--> </div> </body> </html>