Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-83

Suggested changes to scomp

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • unspecified
    • TBD
    • Compiler
    • None

    Description

      Hi,

      I posted to the dev forum a suggested change to scomp to produce a mapping of the XML schema names to the produced XmlBeans java name in xsdconfig format. The email on 5th November, titled "Suggested change to scomp", and contains an attachment with a copy of the amendments to scomp. I suggested that scomp be amended to have a new option -javaname followed by the file name to send the output to.

      To summarise the email we needed a way of producing a list of the XML schema names to the XmlBeans java name, for cases when the mapping was non obvious illustrated below:

      A simple schema with a global element of:

      purchase-order (set as a global element)
      Customer-name (set a a complex type)
      name (set as a simple type, say xs:string)

      causes XmlBeans to create the following:

      PurchaseOrderDocument class
      Method names in the class:
      getPurchaseOrder method returning inner class PurhaseOrder
      PurchaseOrder inner class
      getCustomerName returning class CustomerName

      CustomerName class
      Method names in the class:
      getName returns simple type for xml item 'name' of XmlString

      Because of the name translation performed by XMLBeans on the schema's XML names in producing the Java names we needed a method of producing a list of what we have termed non-obvious names produced by the translation. This would display the translation for instances such as Customer-name above which is translated to CustomerName, but more importantly, instances where XMLBeans has to make the Java name unique by adding a digit to the resulting name (if say the schema had Customer-name and CustomerName). This list can then be used to look up the javaname to use when referencing an Xml name.

      The file is produced in an xsdconfig compatible file format. This file can then be used to look up the name or even remap the names produced if required.

      Here's a couple of lines of the output

      <!-- pathname=/eas:purchase-order/eas:Customer/eas:customer-->
      <xb:qname name="eas:customer" javaname="Customer"/>

      before the mapping is a comment showing the location of the element being mapped and following it is the xsdconfig syntax to perform the mapping. This would then allow the name to be remapped if desired by putting the .xsdconfig file back through scomp.

      So to produce the mapping to easypod.xsdconfig from easypod.xsd the change would use:

      scomp -compiler c:\j2sdk1.4.2_06\bin\javac.exe -jar c:\j2sdk1.4.2_06\bin\jar.exe -javamaps easypod.xsdconfig easypod.xsd

      Paul Adams

      Attachments

        Activity

          People

            radup Radu Preotiuc
            pca Paul Adams
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: