xTuple.com xTupleU Blog & News Customer Support

Xml import

I am new to Xtuple. Kindly advise a sample xslt file and a dtd file other than yahoo api. I want to import sales order and lines for existing customers.

Munira,

The stylesheet you need must be written to match the XML schema or DTD of the sales order file you receive. We can do nothing specific to help without that information. However, the following might help you understand XSLT and learn more about it.

XSLT is a part of the Extensible Stylesheet Language Family defined by the World Wide Web Consortium (W3C). You can find detailed information on their website. The W3C points to a tutorial here and there are lots of books that can help you learn it.

The purpose of the language is to read one XML file and produce a different XML or text file. Here’s a short example:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output indent="yes"/>

 <xsl:template match="*">
   <xsl:copy>
     <xsl:apply-templates select="node()"/>
   </xsl:copy>
  </xsl:template>

  <xsl:template match="text()"/>

</xsl:stylesheet>
  • output indent="yes" - produce indented XML output
  • template match="*" - process each element at the current level in the XML input in turn *1
  • copy - copy the current element
  • apply-templates select="node()" - apply templates for each element that is a direct child of the current element (not exactly but close enough)
  • template match="text()" - if the current element is a text element, not an attribute and not a tag, do nothing *2

*1: This template gets used unless another later on in the stylesheet matches the current element
*2: This template is the only one that appears “later on”. Because it contains no instructions, it produces no output.

For this input:

<?xml version="1.0" encoding="UTF-8"?>
<results>
Checking example.cc...
    <error file="example.cc" line="5" id="unassignedVariable" severity="style" msg="Variable &apos;x&apos; is not assigned a value."/>
    <error file="example.cc" line="6" id="uninitvar" severity="error" msg="Uninitialized variable: x"/>
Checking usage of global functions..
    <error id="missingInclude" severity="style" msg="Cppcheck cannot find all the include files (use --check-config for details)"/>
</results>

the stylesheet produces this output:

<?xml version="1.0"?>
<results>
  <error/>
  <error/>
  <error/>
</results>

Gil

Hi,

Thanks for the read. Was very informative. I am a bit unclear, on how does the import function understand on the insert statements on to which “schema. Tables” in the database. Where is this defined? I know there’s mapping done some where . Can you advise how. And what is xmlimport Document type.

Awaiting your kind advise.

Thanks
Munira

Munira,

The Importing Data page might be the next place for you to look. Pay careful attention to the XML section. The short answer is that the XSLT stylesheet must convert whatever XML you started with into an XML file that has the same structure as the database. The mapping is done by creating elements with the same names as tables, and child elements having the same names as columns.

Gil

Hi

Thanks. Had a careful read and now more clear. Thanks