xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Xmlbeans Wiki] Update of "XmlBeansFaq" by fx
Date Wed, 18 Jul 2012 22:18:56 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xmlbeans Wiki" for change notification.

The "XmlBeansFaq" page has been changed by fx:
http://wiki.apache.org/xmlbeans/XmlBeansFaq?action=diff&rev1=341&rev2=342

Comment:
Added comment for latest release question.

  ## page was renamed from XmlBeansV1Faq
  ##language:en
  #pragma section-numbers off
- 
  = XMLBeans FAQ =
- 
   * '''[[#community|General Community Questions]] * '''
-    * [[#mailingLists|What are the different XMLBeans Mailing Lists?]]
+   * [[#mailingLists|What are the different XMLBeans Mailing Lists?]]
-    * [[#committers|Who are the XMLBeans Committers?]]
+   * [[#committers|Who are the XMLBeans Committers?]]
-    * [[#fileBug|Where do I file a bug for XMLBeans?]]
+   * [[#fileBug|Where do I file a bug for XMLBeans?]]
  
   * '''[[#gettingStarted|Getting Started]]'''
-    * [[#downloadBinary|Where can I download the latest release of XMLBeans?]]
+   * [[#downloadBinary|Where can I download the latest release of XMLBeans?]]
-    * [[#latestVersion|What is the latest version of XMLBeans?]]
+   * [[#latestVersion|What is the latest version of XMLBeans?]]
-    * [[#gettingStartedDoc|How do I get started coding with XMLBeans?]]
+   * [[#gettingStartedDoc|How do I get started coding with XMLBeans?]]
-    * [[#xmlbeansSource|How can I get the latest XMLBeans source code in svn?]]
+   * [[#xmlbeansSource|How can I get the latest XMLBeans source code in svn?]]
-    * [[#buildingXMLBeans|How do I build XMLBeans from source?]]
+   * [[#buildingXMLBeans|How do I build XMLBeans from source?]]
-    * [[#viewXMLBeansOnline|Can I view the XMLBeans Source Code online, without having svn
on my machine?]]
+   * [[#viewXMLBeansOnline|Can I view the XMLBeans Source Code online, without having svn
on my machine?]]
-    * [[#viewJavaDoc|Is the XMLBeans javadoc available online?]]
+   * [[#viewJavaDoc|Is the XMLBeans javadoc available online?]]
-    * [[#whatJars|What jars do I need on the classpath to use XMLBeans?]] 
+   * [[#whatJars|What jars do I need on the classpath to use XMLBeans?]]
-    * [[#qname|Running my code that used to work fails with "java.lang.NoClassDefFoundError:
javax/xml/namespace/QName" after upgrading to 2.3.0]]
+   * [[#qname|Running my code that used to work fails with "java.lang.NoClassDefFoundError:
javax/xml/namespace/QName" after upgrading to 2.3.0]]
-    * [[#scompFindingJavac|The scomp program can't find javac and fails with java.io.IOException
on Windows!]]
+   * [[#scompFindingJavac|The scomp program can't find javac and fails with java.io.IOException
on Windows!]]
-    * [[#scompOutOfMemory|The scomp program gives OutOfMemoryError when compiling my complex
Schema!]]
+   * [[#scompOutOfMemory|The scomp program gives OutOfMemoryError when compiling my complex
Schema!]]
-    * [[#codeTooLarge|The scomp fails with code too large error!]]
+   * [[#codeTooLarge|The scomp fails with code too large error!]]
  
   * '''[[#generalXbeans|General XMLBeans Questions]]'''
-    * [[#PCDATComplexType|How can I write the PCDATA in Element which is complexType?]]
+   * [[#PCDATComplexType|How can I write the PCDATA in Element which is complexType?]]
-    * [[#javaType4SchemaTypes|What Java types are created for a particular schema type?]]
+   * [[#javaType4SchemaTypes|What Java types are created for a particular schema type?]]
-    * [[#configPackageName|Can I change the default package names for the java classes generated
from my schema?]]
+   * [[#configPackageName|Can I change the default package names for the java classes generated
from my schema?]]
-    * [[#deepEquals|Is there a way to do a ''deep equals'' between two Xmlobjects?]]
+   * [[#deepEquals|Is there a way to do a ''deep equals'' between two Xmlobjects?]]
-    * [[#suggestedPrefixes|How can I influence the namespace prefix used when saving/printing
out my XML?]]
+   * [[#suggestedPrefixes|How can I influence the namespace prefix used when saving/printing
out my XML?]]
-    * [[#xsiSchemaLocation|How can I instruct XMLBeans to add the xsi:schemaLocation attribute
to my documents?]]
+   * [[#xsiSchemaLocation|How can I instruct XMLBeans to add the xsi:schemaLocation attribute
to my documents?]]
-    * [[#selectPath|Is selectPath(...) on XmlObject and XmlCursor working?]]
+   * [[#selectPath|Is selectPath(...) on XmlObject and XmlCursor working?]]
-    * [[#execQuery|Is execQuery(...) on XmlObject and XmlCursor working?]]
+   * [[#execQuery|Is execQuery(...) on XmlObject and XmlCursor working?]]
-    * [[#xsdConfig|How do I modify the generated interfaces?]]
+   * [[#xsdConfig|How do I modify the generated interfaces?]]
-    * [[#cdataOptions|How do I control CDATA?]]
+   * [[#cdataOptions|How do I control CDATA?]]
-     
+ 
   * '''[[#somQuestions|Schema Object Model Questions]] '''
-    * [[#introToSTS|Is there an introduction document on the XMLBeans Schema Type System?]]
+   * [[#introToSTS|Is there an introduction document on the XMLBeans Schema Type System?]]
-    * [[#schemaType2Javaname|How do I get the java name for a schema type?]] 
+   * [[#schemaType2Javaname|How do I get the java name for a schema type?]]
-    * [[#schemaAnnotation|How do I get to SchemaAnnotation and SchemaIdentityConstraint on
elements?]]
+   * [[#schemaAnnotation|How do I get to SchemaAnnotation and SchemaIdentityConstraint on
elements?]]
-    * [[#schemaPropertySchemaParticle|What is the difference between SchemaProperty and SchemaParticle?]]
+   * [[#schemaPropertySchemaParticle|What is the difference between SchemaProperty and SchemaParticle?]]
-    * [[#substGroups|How do I use substitution groups?]]
+   * [[#substGroups|How do I use substitution groups?]]
-    * [[#schemaDependencies|How do I compile multiple schema files with dependencies?]]
+   * [[#schemaDependencies|How do I compile multiple schema files with dependencies?]]
  
   * '''[[#xmlCursor|XmlCursor API]]'''
-    * [[#navigatingXmlCursor|Is there documentation on navigating with XmlCursor?]]
+   * [[#navigatingXmlCursor|Is there documentation on navigating with XmlCursor?]]
-    * [[#usingBookmarks|How do I use Bookmarks to annotate XML?]]
+   * [[#usingBookmarks|How do I use Bookmarks to annotate XML?]]
  
  ----
  <<Anchor(community)>>
+ 
  === General Community Questions ===
  ----
- <<Anchor(mailingLists)>>
- '''What are the different XMLBeans Mailing Lists?'''
+ <<Anchor(mailingLists)>> '''What are the different XMLBeans Mailing Lists?'''
  
  [[http://xmlbeans.apache.org/community/index.html#Mailing+Lists|Apache XMLBeans Mailing
Lists]]
  
  ----
- <<Anchor(committers)>>
- '''Who are the XMLBeans Committers?'''
+ <<Anchor(committers)>> '''Who are the XMLBeans Committers?'''
  
  [[http://xmlbeans.apache.org/community/index.html#Who+we+are|Apache XMLBeans Committers]]
  
  ----
- <<Anchor(fileBug)>>
- '''Where do I file a bug for XMLBeans?'''
+ <<Anchor(fileBug)>> '''Where do I file a bug for XMLBeans?'''
  
- XMLBeans uses Jira for bugtracking.  
+ XMLBeans uses Jira for bugtracking.
  
-  * [[https://issues.apache.org/jira/browse/xmlbeans#selectedTab=com.atlassian.jira.plugin.system.project%3Asummary-panel|Go
to XMLBeans JIRA]]
+  * [[https://issues.apache.org/jira/browse/xmlbeans#selectedTab=com.atlassian.jira.plugin.system.project:summary-panel|Go
to XMLBeans JIRA]]
   * [[https://issues.apache.org/jira/browse/xmlbeans|See reporting information of XMLBeans
JIRA issues]]
  
  <<Anchor(gettingStarted)>>
+ 
  === Getting Started ===
  ----
- <<Anchor(latestVersion)>>
- '''What is the latest version of XMLBeans?'''
+ <<Anchor(latestVersion)>> '''What is the latest version of XMLBeans?'''
  
- XMLBeans Version 2.4.0 is the most recent release.  The 1.0.4 release is the latest stable
maintenance release.  You will need JDK 1.4 for the 2.3.0 and 1.0.4 release.  For JDK 1.3
users, there is a version of the 1.0.4 release compatible with JDK 1.3.
+ Check the [[http://xmlbeans.apache.org/news.html|news page]] for the latest release.  The
1.0.4 release is the latest stable maintenance release.  You will need JDK 1.4 for the 2.3.0
and 1.0.4 release.  For JDK 1.3 users, there is a version of the 1.0.4 release compatible
with JDK 1.3. For 2.6.0 release JDK 6 is required.
  
  ----
- <<Anchor(downloadBinary)>>
- '''Where can I download the latest release of XMLBeans?'''
+ <<Anchor(downloadBinary)>> '''Where can I download the latest release of XMLBeans?'''
  
  http://xmlbeans.apache.org/sourceAndBinaries/
+ 
  ----
- <<Anchor(gettingStartedDoc)>>
- '''How do I get started coding with XMLBeans?'''
+ <<Anchor(gettingStartedDoc)>> '''How do I get started coding with XMLBeans?'''
  
  You can find lots of [[http://xmlbeans.apache.org/documentation/index.html|documentation]]
on the XMLBeans' website.  The [[http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html|Getting
Started]] guide (http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html)
is a good introduction to XMLBeans.  Another excellent place to start is the [[http://xmlbeans.apache.org/documentation/tutorial_getstarted.html|tutorial]].
  
  ----
- <<Anchor(xmlbeansSource)>>
- '''How can I get the latest XMLBeans source code in svn?'''
+ <<Anchor(xmlbeansSource)>> '''How can I get the latest XMLBeans source code
in svn?'''
  
  [[http://xmlbeans.apache.org/sourceAndBinaries/index.html#XMLBeans+Source|XMLBeans Source
Code Information]].  You will need a Subversion (svn) client.
+ 
  ----
- <<Anchor(viewJavaDoc)>>
- '''Is the XMLBeans javadoc available online?'''
+ <<Anchor(viewJavaDoc)>> '''Is the XMLBeans javadoc available online?'''
  
  Yes, you can view the XMLBeans [2.5.0 Javadocs], [[http://xmlbeans.apache.org/docs/2.4.0/reference/index.html|2.4.0
JavaDocs]], [[http://xmlbeans.apache.org/docs/2.2.0/reference/index.html|2.2.0 JavaDocs]],
[[http://xmlbeans.apache.org/docs/2.1.0/reference/index.html|2.1.0 JavaDocs]], [[http://xmlbeans.apache.org/docs/2.0.0/reference/index.html|2.0.0
JavaDocs]] or the [[http://xmlbeans.apache.org/docs/1.0.4/reference/index.html|1.0.4 JavaDocs]].
  
  ----
- <<Anchor(whatJars)>>
- '''What jars do I need on the classpath to use XMLBeans?'''
+ <<Anchor(whatJars)>> '''What jars do I need on the classpath to use XMLBeans?'''
  
   * The obvious one is ''xbean.jar'', which contains the XMLBeans code. ''scomp.cmd'' includes
trailing periods after this on v1.0.4, which may cause problems under Windows XP.
   * For XMLBeans V1, this is all you need, but for XMLBeans 2, the JSR173 API jar is also
required, since it contains classes that XMLBeans depends on. For XMLBeans 2.0.0, the name
of the jar is ''jsr173_api.jar'' and for XMLBeans 2.1.0, it's ''jsr173_1.0_api.jar''. In both
cases, the jar comes with the XMLBeans binary distribution (for source distributions, the
build process will download it and place it in the ''build/lib'' directory.
   * For JDK 1.4 users, as of XMLBeans 2.3.0 it has become necessary to also include xmlbeans-qname.jar
   * If XPath/XQuery support is required, the ''xbean_xpath.jar'' contains the XPath "glue"
code and needs to be included on the classpath. Then, depending on the version of XMLBeans
in use, the following are also required: ''jaxen.jar'' for XMLBeans V1 (only supports XPath,
no XQuery), ''saxon8.jar'' for XMLBeans V2.0.0 and V2.1.0 (the only version supported is Saxon
8.1.1), ''saxon8.jar'' and ''saxon8-dom.jar'' for XMLBeans built from SVN head (this supports
Saxon >= 8.6.1).
-   ||XMLBeans version||Saxon supported version||
+   ||XMLBeans version ||Saxon supported version ||
-   ||v2.4.0||Saxon-9.0.0.4||
+   ||v2.4.0 ||Saxon-9.0.0.4 ||
-   ||v2.3.0||Saxon-8.8||
+   ||v2.3.0 ||Saxon-8.8 ||
-   ||v2.2.0||SaxonB-8.6.1||
+   ||v2.2.0 ||SaxonB-8.6.1 ||
-   ||v2.1.0||SaxonB-8.1.1||
+   ||v2.1.0 ||SaxonB-8.1.1 ||
-   ||v2.0.0||SaxonB-8.1.1||
+   ||v2.0.0 ||SaxonB-8.1.1 ||
-   ||v1.x||N/A||
+   ||v1.x ||N/A ||
  
  
+ 
-  * In addition to those, compiling Schemas using the scomp script requires ''tools.jar''
from the JDK and ''resolver.jar'' from Apache xml-commons (the latter one only in case support
for OASIS XML catalogs for resolving external entities is needed). 
+  * In addition to those, compiling Schemas using the scomp script requires ''tools.jar''
from the JDK and ''resolver.jar'' from Apache xml-commons (the latter one only in case support
for OASIS XML catalogs for resolving external entities is needed).
   * We make another jar available, ''xmlpublic.jar'', which contains the classes in the "org.apache.xmlbeans"
package. If your code can be compiled with ''xmlpublic.jar'' on the classpath instead of the
full ''xbean.jar'', it means that your code uses only "public", supported APIs and will likely
not need any modification if you need to upgrade to a newer XMLBeans version.
+ 
  ----
- <<Anchor(qname)>>
- '''Running my code that used to work fails with "java.lang.!NoClassDefFoundError: javax/xml/namespace/QName"
after upgrading to 2.3.0'''
+ <<Anchor(qname)>> '''Running my code that used to work fails with "java.lang.!NoClassDefFoundError:
javax/xml/namespace/QName" after upgrading to 2.3.0'''
  
  See [[#whatJars|What jars do I need on the classpath to use XMLBeans?]]. You need to add
xmlbeans-qname.jar on you classpath.
+ 
  ----
- <<Anchor(scompFindingJavac)>>
- '''The scomp program can't find javac and fails with java.io.IOException on Windows!'''
+ <<Anchor(scompFindingJavac)>> '''The scomp program can't find javac and fails
with java.io.IOException on Windows!'''
  
  On Windows, some users have reported that the scomp program fails when trying to run javac
on the generated java source.  First, be sure you have a JDK installed.  The JRE doesn't have
the javac program so you won't be able to compile the generated java source.  If you have
both a JDK and a JRE installed, the JRE's java is being found before the JDK's java.  Since
scomp uses the 'java.home' property to find the javac program, but javac is only available
in the JDK, finding javac will fail.
  
@@ -154, +148 @@

          at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:264)
  BUILD FAILED
  }}}
- 
- If that doesn't fix the issue, try specifying relevant paths using Windows 8.3 names. This
will get around issues with spaces in folder names. 
+ If that doesn't fix the issue, try specifying relevant paths using Windows 8.3 names. This
will get around issues with spaces in folder names.
  
  ----
- <<Anchor(scompOutOfMemory)>>
- '''The scomp program gives !OutOfMemoryError when compiling my complex Schema!'''
+ <<Anchor(scompOutOfMemory)>> '''The scomp program gives !OutOfMemoryError when
compiling my complex Schema!'''
  
  The likely problem here is that because of the large number of source files that must be
generated sometimes, the javac compilation step fails with insufficient memory. Here's how
the problem manifests itself:
  
@@ -173, +165 @@

  Consult the following stack trace for details.
  java.lang.OutOfMemoryError
  }}}
- 
- If you get this, you need to give javac more memory. But since javac is launched as an external
process, tweaking the scomp.bat script and upping the memory that scomp has available will
have no effect.
+ If you get this, you need to give javac more memory. But since javac is launched as an external
process, tweaking the scomp.bat script and upping the memory that scomp has available will
have no effect. The solution is to use the "-mx" parameter to scomp, for example:
- The solution is to use the "-mx" parameter to scomp, for example:
+ 
  {{{
  $ scomp -mx 1024M myBigSchema.xsd
  }}}
  ----
- <<Anchor(codeTooLarge)>>
- '''The scomp fails with code too large error'''
+ <<Anchor(codeTooLarge)>> '''The scomp fails with code too large error'''
  
- This issue has been seen when running scomp xsds from www.niem.gov and www.it.ojp.gov/jxdm.
When encountered in the schemas above is caused by a limitation of the JVM. It was discovered
and noted by a JIRA issue. 
+ This issue has been seen when running scomp xsds from www.niem.gov and www.it.ojp.gov/jxdm.
When encountered in the schemas above is caused by a limitation of the JVM. It was discovered
and noted by a JIRA issue.
  
- [[http://issues.apache.org/jira/browse/XMLBEANS-307]]
+ http://issues.apache.org/jira/browse/XMLBEANS-307
  
  The scomp tool does not currently have a solution for this.
+ 
  ----
+ <<Anchor(buildingXMLBeans)>> '''How do I build XMLBeans?'''
- <<Anchor(buildingXMLBeans)>>
- '''How do I build XMLBeans?'''
  
  [[http://xmlbeans.apache.org/sourceAndBinaries/index.html#Building+XMLBeans|Building XMLBeans]].
 You will need [[http://ant.apache.org/|Ant]] installed and JDK 1.4.
+ 
  ----
- <<Anchor(viewXMLBeansOnline)>>
- '''Can I view the XMLBeans source code online, without having svn on my machine?'''
+ <<Anchor(viewXMLBeansOnline)>> '''Can I view the XMLBeans source code online,
without having svn on my machine?'''
  
  Yes you can use the CVS/SVNView to browse or link to the XMLBeans source code.  [[http://svn.apache.org/viewcvs.cgi/xmlbeans/trunk/|Link
to XMLBeans main dev trunk]]
  
  ----
  <<Anchor(generalXbeans)>>
+ 
  === General XMLBeans Questions ===
  ----
- <<Anchor(javaType4SchemaTypes)>>
- '''What Java types are created for a particular schema type?'''
+ <<Anchor(javaType4SchemaTypes)>> '''What Java types are created for a particular
schema type?'''
  
-   '''User Derived Schema Types'''
+  . '''User Derived Schema Types''' When you compile XML schema, the resulting API is made
up of two categories of types: built-in types that mirror those in the schema specification
and others that are generated from user-derived schema types. This topic provides an overview
of the Java types generated for user-derived types, describing the methods the Java types
provide ...  [[http://xmlbeans.apache.org/docs/2.0.0/guide/conJavaTypesGeneratedFromUserDerived.html|Java
Types Generated from User-Derived Schema Types]] '''Built in Types''' Just as with types in
XML schema, the XMLBeans types based on schema are arranged in a hierarchy. In general, the
hierarchy of XMLBean types mirrors the hierarchy of the schema types themselves. XML schema
types all inherit from xs:anyType (which is at the root of the hierarchy); XMLBeans types
inherit from !XmlObject ... [[http://xmlbeans.apache.org/docs/2.0.0/guide/conXMLBeansSupportBuiltInSchemaTypes.html|XMLBeans
Support for Built-In Schema Types]]
  
-   When you compile XML schema, the resulting API is made up of two categories of types:
built-in types that mirror those in the schema specification and others that are generated
from user-derived schema types. This topic provides an overview of the Java types generated
for user-derived types, describing the methods the Java types provide ...  [[http://xmlbeans.apache.org/docs/2.0.0/guide/conJavaTypesGeneratedFromUserDerived.html|Java
Types Generated from User-Derived Schema Types]]
- 
-   '''Built in Types'''
- 
-   Just as with types in XML schema, the XMLBeans types based on schema are arranged in a
hierarchy. In general, the hierarchy of XMLBean types mirrors the hierarchy of the schema
types themselves. XML schema types all inherit from xs:anyType (which is at the root of the
hierarchy); XMLBeans types inherit from !XmlObject ... [[http://xmlbeans.apache.org/docs/2.0.0/guide/conXMLBeansSupportBuiltInSchemaTypes.html|XMLBeans
Support for Built-In Schema Types]]
- 
  ----
- <<Anchor(configPackageName)>>
- '''Can I change the default package names for the java classes generated from my schema?'''
+ <<Anchor(configPackageName)>> '''Can I change the default package names for
the java classes generated from my schema?'''
  
  You can create a file that ends in .xsdconfig to map targetnamespace to packagename.  Put
the .xsdconfig file in the same directory as the .xsd that you are compiling.  Here is an
example .xsdconfig:
+ 
  {{{
- <!-- An xsdconfig file must begin with a "config" element in the 
+ <!-- An xsdconfig file must begin with a "config" element in the
          http://www.bea.com/2002/09/xbean/config namespace. Also, be sure
          to declare any namespaces used to qualify types in your schema (here,
          the namespace corresponding to the pol prefix. -->
- <xb:config xmlns:pol="http://openuri.org/easypoLocal" 
+ <xb:config xmlns:pol="http://openuri.org/easypoLocal"
      xmlns:xb="http://www.bea.com/2002/09/xbean/config">
  
      <!-- Use the "namespace" element to map a namespace to the Java package
@@ -235, +219 @@

  
      <!-- Use the "qname" element to map schema type names to generated
          Java type names. In these examples, the name attribute's value is the
-         XML element name; the javaname attribute's value is the Java type 
+         XML element name; the javaname attribute's value is the Java type
          that should be generated. -->
      <xb:qname name="pol:CUST" javaname="Customer"/>
      <xb:qname name="pol:PURCH_ORDER" javaname="PurchaseOrder"/>
  </xb:config>
  }}}
- 
  Notice that you can also map specific element/attribute names to java names.
  
  /!\ Note: If schema doesn't include targenamespace then use
+ 
  {{{
  <xb:namespace uri="##any">
    <xb:package>org.openuri.easypo.xsdconfig</xb:package>
@@ -255, +239 @@

  /!\ Note: XMLBeans doesn’t support using two or more sets of java classes (in different
packages) mapped to schema types/elements that have the same names and target namespaces,
using all in the same class loader. Depending on the direction you are using for the java
classes to schema types mapping, some features might not work correctly. This is because even
though the package names for the java classes are different, the schema location for the schema
metadata (.xsb files) is the same and contains the corresponding implementing java class,
so the JVM will always pick up the first on the classpath. This can be avoided if multiple
class loaders are used.
  
  ----
- <<Anchor(deepEquals)>>
- '''Is there a way to do a ''deep equals'' between two !XmlObjects?'''
+ <<Anchor(deepEquals)>> '''Is there a way to do a ''deep equals'' between two
!XmlObjects?'''
  
  Dmitri.Colebatch posted some code that will do a ''deep equals''.  You can find the code
attached to this post http://nagoya.apache.org/eyebrowse/ReadMsg?listName=xmlbeans-user@xml.apache.org&msgNo=75
  
  Kevin Krouse also posted some code that will do a ''deep equals'' but had some limitations
addressed by Dmitri above.  You can find the code attached to this post http://nagoya.apache.org/eyebrowse/ReadMsg?listName=xmlbeans-user@xml.apache.org&msgNo=69.
  
  ----
- <<Anchor(suggestedPrefixes)>> 
- '''How can I influence the namespace prefix used when saving/printing out my XML?'''
+ <<Anchor(suggestedPrefixes)>>  '''How can I influence the namespace prefix used
when saving/printing out my XML?'''
  
- XMLBeans does not keep the prefixes when the original XML is loaded into the underlying
XML store.  If you need/want a specific prefix to be associated with a namespace you can use
the {{{setSaveSuggestedPrefixes(...)}}} !XmlOption.  
+ XMLBeans does not keep the prefixes when the original XML is loaded into the underlying
XML store.  If you need/want a specific prefix to be associated with a namespace you can use
the {{{setSaveSuggestedPrefixes(...)}}} !XmlOption.
  
  Here is a code example from this helpful post, http://nagoya.apache.org/eyebrowse/ReadMsg?listName=xmlbeans-user@xml.apache.org&msgNo=33
:
+ 
  {{{
  HashMap suggestedPrefixes = new HashMap();
  suggestedPrefixes.put("http://foo.com/", "foo");
@@ -277, +260 @@

  
  String output = document.xmlText(opts);
  }}}
- 
  ----
- <<Anchor(xsiSchemaLocation)>>
- '''How can I instruct XMLBeans to add the xsi:schemaLocation attribute to my documents?'''
+ <<Anchor(xsiSchemaLocation)>> '''How can I instruct XMLBeans to add the xsi:schemaLocation
attribute to my documents?'''
  
  Here's how to do it. Assume that you have a document represented by the ''doc'' !XmlObject
 (obtained via !TestDocument.Factory.newInstance() or !TestDocument.Factory.parse()) and you
need an xsi:schemaLocation attribute on it, with value from the ''location'' String.
+ 
  {{{
  XmlCursor cursor = doc.newCursor();
  if (cursor.toFirstChild())
@@ -290, +272 @@

    cursor.setAttributeText(new QName("http://www.w3.org/2001/XMLSchema-instance","schemaLocation"),
location);
  }
  }}}
- 
  ----
- <<Anchor(selectPath)>>
- '''Is selectPath(...) on !XmlObject and !XmlCursor working?'''
+ <<Anchor(selectPath)>> '''Is selectPath(...) on !XmlObject and !XmlCursor working?'''
  
  XMLBeans has a built in engine for very simple XPath expressions.  To use more advanced
XPath or XQuery expressions in 2.x, you will need [[http://saxon.sf.net/|Saxon]] on the classpath.
'''NOTE''': See [[#whatJars|supported versions of Saxon]].
  
  To use more advanced XPath expressions in 1.0.4, the Jaxen engine can be used if xbean_xpath.jar
is on the classpath. The xbean_xpath.jar is available in build\private\lib by running 'ant
xbean_xpath.jar'.
  
  ----
- <<Anchor(execQuery)>>
- '''Is execQuery(...) on !XmlObject and !XmlCursor working?'''
+ <<Anchor(execQuery)>> '''Is execQuery(...) on !XmlObject and !XmlCursor working?'''
  
  Yes!  XMLBeans 2.1.0 uses [[http://saxon.sf.net/|Saxon]] as its XQuery engine so you will
need it on your classpath.  '''NOTE''': See [[#whatJars|supported versions of Saxon]].
  
  For the 1.0.4 release, there is no open source XQuery integration.  However, the !XmlBeans
included in BEA's Weblogic 8.x executes xqueries using a BEA's proprietary XQuery engine.
  
  ----
- <<Anchor(xsdConfig)>>
- '''How do I modify the generated interfaces?'''
+ <<Anchor(xsdConfig)>> '''How do I modify the generated interfaces?'''
  
  Use .xsdconfig files. Learn more here - XsdConfigFile.
  
  ----
+ <<Anchor(cdataOptions)>> '''How do I control CDATA?'''
- <<Anchor(cdataOptions)>>
- '''How do I control CDATA?'''
  
  Use CDATA options. Learn more here - CdataOptions.
  
  ----
  <<Anchor(somQuestions)>>
+ 
  === Schema Object Model Questions ===
  ----
- <<Anchor(introToSTS)>>
- '''Is there an introduction document on the XMLBeans Schema Type System?'''
+ <<Anchor(introToSTS)>> '''Is there an introduction document on the XMLBeans
Schema Type System?'''
  
  This [[http://xmlbeans.apache.org/docs/2.0.0/guide/conIntroToTheSchemaTypeSystem.html|document]]
is a good starting place to learn about programming against the XMLBeans Schema Type System.
  
  ----
- <<Anchor(schemaType2Javaname)>>
- '''How do I get the java name for a schema type?'''
+ <<Anchor(schemaType2Javaname)>> '''How do I get the java name for a schema type?'''
  
-    1. Once you've compiled things and got the JAR...
+  1. Once you've compiled things and got the JAR...
  
-    1. Put the JAR on your classpath
+  1. Put the JAR on your classpath
  
-    1. Use {{{com.bea.xml.XmlBeans.getContextTypeLoader()}}} to get the !SchemaTypeLoader
corresponding to your thread's context classloader.
+  1. Use {{{com.bea.xml.XmlBeans.getContextTypeLoader()}}} to get the !SchemaTypeLoader corresponding
to your thread's context classloader.
  
-    1. you can then use {{{schemaTypeLoader.findType(QNameForType)}}}
+  1. you can then use {{{schemaTypeLoader.findType(QNameForType)}}}
  
-    1. and then  {{{type.getFullJavaName()}}}
+  1. and then  {{{type.getFullJavaName()}}}
  
-   see this post: http://nagoya.apache.org/eyebrowse/ReadMsg?listName=xmlbeans-user@xml.apache.org&msgNo=7
''@fixme: seems to be a dead link''
+  1. see this post: http://nagoya.apache.org/eyebrowse/ReadMsg?listName=xmlbeans-user@xml.apache.org&msgNo=7
''@fixme: seems to be a dead link''
  
  ----
- <<Anchor(schemaAnnotation)>>
- '''How do I get to !SchemaAnnotation and !SchemaIdentityConstraint on elements?'''
+ <<Anchor(schemaAnnotation)>> '''How do I get to !SchemaAnnotation and !SchemaIdentityConstraint
on elements?'''
  
  See below [[#schemaPropertySchemaParticle|What is the difference between SchemaProperty
and SchemaParticle?]]
  
  ----
- <<Anchor(schemaPropertySchemaParticle)>>
- '''What is the difference between !SchemaProperty and !SchemaParticle?'''
+ <<Anchor(schemaPropertySchemaParticle)>> '''What is the difference between !SchemaProperty
and !SchemaParticle?'''
  
  In a few words, the difference is that !SchemaProperty represents a "flattened", simplified
view of the contents of a type, while !SchemaParticle represents a "complete" view including
all of the model groups, as defined in Schema. To exemplify, consider the following Schema:
  
  {{{<xs:complexType name="T">
+ 
-   <xs:sequence>
+  . <xs:sequence>
-     <xs:element name="a" type="xs:string"/>
+   . <xs:element name="a" type="xs:string"/> <xs:choice>
+    . <xs:element name="a" type="xs:string" maxOccurs="unbounded" tns:ann="annotation_a"/>
<xs:element name="b" type="xs:string" maxOccurs="unbounded"/>
-     <xs:choice>
-       <xs:element name="a" type="xs:string" maxOccurs="unbounded" tns:ann="annotation_a"/>
-       <xs:element name="b" type="xs:string" maxOccurs="unbounded"/>
-     </xs:choice>
+   </xs:choice>
-   </xs:sequence>    
+  </xs:sequence>
+ 
  </xs:complexType>}}}
  
  As you can see, this content mandates an <a> element in the instance, followed by
either one or more <a>s or one or more <b>s (a (a+|b+)). The majority of applications
would only be interested in what are the names and types of elements allowed inside the content
for type "T" and would not care whether there are nested sequeces/choices and the like. As
such, they can use {{{SchemaType.getProperties()}}} and they will see two entries, one for
element "a" (built by collapsing the two occurences of an "a" element in the Schema) and one
for element "b".
@@ -372, +346 @@

  
  This example code illustrate how to get the !SchemaProperty'ies and !SchemaParticle's on
a type:
  
- {{{   
+ {{{
      SchemaType t = XmlBeans.getContextTypeLoader().findType(new QName("http://test", "T"));
      SchemaProperty[] schemaProperties = t.getProperties();
      for (int i = 0; i < schemaProperties.length; i++)
@@ -409, +383 @@

      }
  }}}
  With helper methods
+ 
  {{{
      public static void printPropertyInfo(SchemaProperty p)
      {
@@ -433, +408 @@

      }
  }}}
  this is the result of running this code:
+ 
  {{{
  Property name="a", type="{http://www.w3.org/2001/XMLSchema}string", maxOccurs="unbounded"
  Property name="b", type="{http://www.w3.org/2001/XMLSchema}string", maxOccurs="unbounded"
@@ -443, +419 @@

  Element name="b", type="{http://www.w3.org/2001/XMLSchema}string", maxOccurs="unbounded"
  }}}
  As you can see, using the !SchemaParticle API we get two occurences for the "a" element
and an annotation showing up only on the second of these occurences.
+ 
  ----
- <<Anchor(substGroups)>>
- '''How do I use substitution groups?'''
+ <<Anchor(substGroups)>> '''How do I use substitution groups?'''
  
  See the Substitution Groups FAQ: SubstGroupsFaq
+ 
  ----
- <<Anchor(schemaDependencies)>>
- '''How do I compile multiple schema files with dependencies?'''
+ <<Anchor(schemaDependencies)>> '''How do I compile multiple schema files with
dependencies?'''
  
- Schema files need to be compiled with its compiled dependencies on the classpath.
- For example, if s4.xsd and s3.xsd depends on s2.xsd which depends on s1.xsd, compile using
the following:
+ Schema files need to be compiled with its compiled dependencies on the classpath. For example,
if s4.xsd and s3.xsd depends on s2.xsd which depends on s1.xsd, compile using the following:
+ 
  {{{
  scomp -out s1.jar s1.xsd
  scomp -cp s1.jar -out s2.jar s2.xsd
  scomp -cp s1.jar;s2.jar -out s3.jar s3.xsd s4.xsd
  }}}
- 
  ----
  <<Anchor(xmlCursor)>>
+ 
  === XmlCursor API ===
  ----
- <<Anchor(navigatingXmlCursor)>>
- '''Is there documentation on navigating with !XmlCursor?'''
+ <<Anchor(navigatingXmlCursor)>> '''Is there documentation on navigating with
!XmlCursor?'''
  
  This document, http://xmlbeans.apache.org/docs/2.0.0/guide/conNavigatingXMLwithCursors.html,
discusses using !XmlCursor to navigate a document.
  
  ----
- <<Anchor(usingBookmarks)>>
- '''How do I use Bookmarks to annotate XML?'''
+ <<Anchor(usingBookmarks)>> '''How do I use Bookmarks to annotate XML?'''
  
  This [[http://xmlbeans.apache.org/docs/2.0.0/guide/conUsingBookmarksToAnnotateXML.html|document]],
http://xmlbeans.apache.org/docs/2.0.0/guide/conUsingBookmarksToAnnotateXML.html, discusses
using bookmarks to annotate xml.
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message