Wednesday, August 15, 2012

XML Programming Basics with the Magic XPA Application Platform

XML is so commonplace today, that we may tend to forget what it really is and what it really does or does not do. First off, XML stands for Extensible Markup Language.  XML uses a flexible standards-based format, which enables you to easily share data. Unlike HTML whose purpose is to display data, XML’s purpose is simply to provide a format by which one can store and transport data. Unlike HTML, there are no predefined tags.

I made up my own tags for this example:

  <blog_name>Magic Application Platform</blog_name>

XML doesn’t do anything by itself, it is simply formatted data. Someone must write software to send, receive or display  XML. That’s where the Magic xpa Application Platform comes into the picture.

Magic xpa provides you with the ability to use XML documents as a standard data source in your applications. You can define an XML data source (XML view) in the Data repository and define a task to manipulate and handle the XML data.  
When using an XML data source, you can create Magic xpa tasks (Batch, Rich Client and Online) that read and manipulate XML documents using XML views. The XML views can be defined in tasks either as a main source or as a linked source.
You can also verify the validity of XML documents using the XMLValidate and XMLValidationError functions. XML schema namespaces are automatically handled by Magic xpa. XML and XSD files that use namespaces do not require any applicative translation between aliases and URIs.  

Earlier versions provided functions for working with XML, but XML manipulation is even easier with Magic xpa today. Now you can work with XML using the XML data source.
The following are provided by Magic xpa to enable you to work with XML data sources:
      1. The XML File entry in the DBMS repository
      2. The XML Defaults tab in the DBMS Properties dialog box
      3. The Temporary Data Source property in the Database Properties dialog box
      4. The XSD section in the Column Properties sheet
Defining an XML data source is done by loading definitions from an XML schema (XSD). If you do not  have a schema that describes the XML document structure that you want to work with, you should use an external tool, such as XMLSpy®, to generate the XML schema.
When parked on a line in the Data repository, you can define a single view for a specific XML schema.
When parked on top of the Data repository (# column), this utility will generate all required views for the XML schema and optionally will generate programs for reading and writing XML documents that are based on this schema. This method lets us reload schemas in order to update existing views.
If the schema file that you selected has several global elements (roots), the Root Selection list will appear. Select one of the roots in order to load it. For schemas with defined namespaces, the namespace URI will be displayed next to the global element name.
When you get the definition of an XML schema, and the Name column has no value, the column will be assigned with a default value: <schema file name with the suffix>.<root element name>. For example: If you use a file called "po.xsd", the name that will appear in the Name column will be "po.purchaseOrder".

Similarly, if the Data source name column has no value, the column will be assigned with a default value: <root element name>.xml . For example: If you use a file called "po.xsd", the name that will appear in the Data source namecolumn will be "purchaseOrder.xml".

To restrict the number of complex elements parsed from a schema (XML views), use the SpecialSchemaSizeLimit setting.

In our next entry, XML Deep Dive with the Magic xpa Application Platform, we’ll more fully explore the detailed usage of XML in Magic xpa. For a detailed look at XML Handling or XSLT for XML Transformations in the Magic xpi Integration Platform see the Integrate My JDE blog which covers JD Edwards ERP integration and a very wide array of related topics. 

No comments:

Post a Comment