title: Creating XML file that fits certain rules that are in xsl and xslt files?
body: <p>Background: I don't have much experience with XML. I've got an out of the box application which works with xml schemas and templates. The process is this:</p>
  
  <ol>
  <li>I should put properly formatted and named xml file in the "Download/Data" folder</li>
  <li>Program detects the file in the "Download/Data" folder, reads it, updates the database using code in xslt files. Xml file is moved into "Download/Processed" folder.</li>
  <li>If the original xml file is not formatted properly, it is moved into  "Download/Invalid" folder.</li>
  </ol>
  
  <p>Problem: I need to create xml file that will pass the validation which is properly formatted and will update the database.
  My current file name is vattaxes.xml and looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
      &lt;VATTax&gt;
        &lt;ProcessingDateTime&gt;
    &lt;/ProcessingDateTime&gt;
    &lt;AdditionalInfo&gt;
    &lt;/AdditionalInfo&gt;
      &lt;Header&gt;
      &lt;VERSION&gt;5.0.1.7&lt;/VERSION&gt;
      &lt;StoreId&gt;1&lt;/StoreId&gt;
      &lt;CreationDate&gt;20140903&lt;/CreationDate&gt;
      &lt;CreationTime&gt;080636&lt;/CreationTime&gt;
      &lt;CreatedOn&gt;TPVIRTUAL-PC&lt;/CreatedOn&gt;
      &lt;Provider&gt;TP.net&lt;/Provider&gt;
      &lt;Customer&gt;
      &lt;/Customer&gt;
      &lt;Subject&gt;StoreConfigBase&lt;/Subject&gt;
      &lt;TruncateFields&gt;0&lt;/TruncateFields&gt;
    &lt;/Header&gt;
              &lt;createDate&gt;20140903&lt;/createDate&gt; 
              &lt;createTime&gt;082056&lt;/createTime&gt;
              &lt;actionCode&gt;2&lt;/actionCode&gt;
              &lt;actionDescription&gt;ADD&lt;/actionDescription&gt;          
              &lt;VATCode&gt;5&lt;/VATCode&gt;
              &lt;VATLongDescription&gt;20% tax&lt;/VATLongDescription&gt;
              &lt;VATShortDescription&gt;20% tax&lt;/VATShortDescription&gt;
              &lt;VATRate&gt;20&lt;/VATRate&gt;
              &lt;VATStartDate&gt;2014-09-02&lt;/VATStartDate&gt;
              &lt;VATEndDate&gt;2015-09-03&lt;/VATEndDate&gt;
              &lt;lastUser&gt;1&lt;/lastUser&gt;  
  &lt;/VATTax&gt;
  </code></pre>
  
  <p>The xsd file that checks whether my file is valid looks like this and is named GV5_VAT.xsd: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsd:schema xmlns="http://www.gold-solutions.com/GoldSchemas"    
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:gold="http://www.gold-solutions.com/GoldSchemas"
          targetNamespace="http://www.gold-solutions.com/GoldSchemas"
          elementFormDefault="qualified"  attributeFormDefault="unqualified"&gt;
  &lt;xsd:annotation&gt;
      &lt;xsd:documentation xml:lang="en"&gt;
      G.O.L.D. V5 TVAs schema V1.0
      Copyright Aldata 2005
      &lt;/xsd:documentation&gt;
  &lt;/xsd:annotation&gt;
  
  &lt;xsd:element name="vattaxes"&gt;
      &lt;xsd:complexType&gt;
          &lt;xsd:sequence&gt;
              &lt;xsd:element name="VATTax" type="VATTaxType" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;/xsd:sequence&gt;
          &lt;xsd:attribute name="processid" type="xsd:integer" use="required"/&gt;
      &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  
  &lt;xsd:complexType name="VATTaxType"&gt;
      &lt;xsd:sequence&gt;
          &lt;xsd:element name="header"&gt;
              &lt;xsd:complexType&gt;
                  &lt;xsd:sequence&gt;
                      &lt;xsd:element name="createDate" type="xsd:date"/&gt;
                      &lt;xsd:element name="createTime" type="xsd:dateTime"/&gt;
                      &lt;xsd:element name="actionCode" type ="xsd:integer"/&gt;
                      &lt;xsd:element name="actionDescription" type="xsd:string"/&gt;
                  &lt;/xsd:sequence&gt;
              &lt;/xsd:complexType&gt;
          &lt;/xsd:element&gt;
          &lt;xsd:element name="VATCode" type="xsd:integer"/&gt;
          &lt;xsd:element name="VATLongDescription" type="xsd:string"/&gt;
          &lt;xsd:element name="VATShortDescription" type="xsd:string"/&gt;
          &lt;xsd:element name="VATSystemCode" type="xsd:integer"/&gt;
          &lt;xsd:element name="VATSystemDescription" type="xsd:string"/&gt;
          &lt;xsd:element name="VATRate" type="xsd:decimal"/&gt;
          &lt;xsd:element name="VATStartDate" type="xsd:date"/&gt;
          &lt;xsd:element name="VATEndDate" type="xsd:date"/&gt;
          &lt;xsd:element name="lastUser" type="xsd:string"/&gt;
      &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;  
      &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>I also have GV5_VAT.xsl</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:gold="http://www.gold-solutions.com/GoldSchemas"
  exclude-result-prefixes="gold"&gt;
  
  &lt;xsl:output method="xml" indent="yes" encoding="utf-8" /&gt;
  
  &lt;!-- Include the header --&gt;
  &lt;xsl:include    
     href="GV5_Base.xsl" /&gt;
  
  &lt;!--
  Template: match the document (processing starts here)
  --&gt;
  &lt;xsl:template match="/"&gt;
      &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;
  
  &lt;!--
  Template: match the root element
  --&gt;
  &lt;xsl:template name="vattaxes" match="/gold:vattaxes" &gt;
      &lt;UpdateDB&gt;
          &lt;xsl:call-template name="BuildHeader" /&gt;
          &lt;xsl:for-each select="./gold:VATTax"&gt;
              &lt;xsl:call-template name="vattax" /&gt;
          &lt;/xsl:for-each&gt;
      &lt;/UpdateDB&gt;
  &lt;/xsl:template&gt;
  
  &lt;!--
  Template: match the single nodeRelation element
  --&gt; 
  &lt;xsl:template name="vattax" &gt;
      &lt;Transaction&gt;
          &lt;!-- Not used elements : --&gt;
          &lt;!--
              &lt;xsd:element name="VATSystemCode" type="xsd:integer"/&gt;
              &lt;xsd:element name="VATSystemDescription" type="xsd:string"/&gt;
              &lt;xsd:element name="lastUser" type="xsd:string"/&gt;
          --&gt;
  
          &lt;xsl:variable name="szPrintCode" select="./gold:VATShortDescription" /&gt;
          &lt;xsl:variable name="szExternalID" select="./gold:VATCode" /&gt;
          &lt;xsl:variable name="szName" select="./gold:VATLongDescription" /&gt;
          &lt;xsl:variable name="dTaxPercent" select="./gold:VATRate" /&gt;
          &lt;xsl:variable name="szEffectiveDate" select="concat(concat(substring  (./gold:VATStartDate,1,4), substring(./gold:VATStartDate,6,2)), substring(./gold:VATStartDate,9,2))" /&gt;
          &lt;xsl:variable name="szExpirationDate" select="concat(concat(substring(./gold:VATEndDate,1,4), substring(./gold:VATEndDate,6,2)), substring(./gold:VATEndDate,9,2))" /&gt;
  
          &lt;!-- Operation selector --&gt;
          &lt;xsl:variable name="actionCode" select="./gold:ACTIONCODE" /&gt;
  
          &lt;xsl:choose&gt;
              &lt;!-- from here changes for release 3.5 T.S. 05.02.2008 mer-X Software GmbH --&gt;
  
              &lt;!-- Insert --&gt;
              &lt;xsl:when test="$actionCode = '2'"&gt;
  
          *** sql inserts below***
  </code></pre>
  
  <p>And the above mentioned GV5_Base.xsl</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
   &lt;xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:gold="http://www.gold-solutions.com/GoldSchemas"
  &gt;
  
  &lt;xsl:output method="xml" indent="yes" encoding="utf-8" /&gt;
  
  &lt;xsl:variable name="parHeaderCreationDate" /&gt;
  &lt;xsl:variable name="parHeaderCreationTime" /&gt;
  &lt;xsl:variable name="parHeaderCreatedOn" /&gt;
  &lt;xsl:variable name="parHeaderSubject" /&gt;
  
  
  &lt;!--
      Template: build header
    --&gt;
  &lt;xsl:template name="BuildHeader"&gt;
      &lt;Header&gt;
          &lt;Version&gt;3.5.0.0&lt;/Version&gt;
          &lt;CreationDate&gt;&lt;xsl:value-of select="$parHeaderCreationDate"/&gt;&lt;/CreationDate&gt;
          &lt;CreationTime&gt;&lt;xsl:value-of select="$parHeaderCreationTime"/&gt;&lt;/CreationTime&gt;
          &lt;CreatedOn&gt;&lt;xsl:value-of select="$parHeaderCreatedOn"/&gt;&lt;/CreatedOn&gt;
          &lt;Provider&gt;Aldata Gold&lt;/Provider&gt;
          &lt;iDocType&gt;positems&lt;/iDocType&gt;
          &lt;Customer&gt;WN&lt;/Customer&gt;
          &lt;Subject&gt;&lt;xsl:value-of select="$parHeaderSubject"/&gt;&lt;/Subject&gt;
          &lt;TruncateFields&gt;1&lt;/TruncateFields&gt;
      &lt;/Header&gt;
  &lt;/xsl:template&gt;
     &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The file which is calling them all is fairly straightforward:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;PARAMETERS&gt;
  &lt;Conversion&gt;
      &lt;!--&lt;DownloadFolder&gt;C:\siirto\tuotanto\pos\in&lt;/DownloadFolder&gt;--&gt;
      &lt;Assembly&gt;not important&lt;/Assembly&gt;
      &lt;Class&gt;not important&lt;/Class&gt;
      &lt;Mappings&gt;
      &lt;Mapping name="VAT" &gt;
              &lt;sourceschema validate="true"&gt;GV5_VAT.xsd&lt;/sourceschema&gt;
              &lt;sourceidentifier&gt;/*[local-name() = 'vattaxes' and namespace-uri() = 'http://www.gold-solutions.com/GoldSchemas']&lt;/sourceidentifier&gt;
              &lt;xsltfile encoding="UTF-8"&gt;GV5_VAT.xsl&lt;/xsltfile&gt;
          &lt;/Mapping&gt;
      &lt;/Mappings&gt;
  &lt;/Conversion&gt;
  &lt;/PARAMETERS&gt;
  </code></pre>
  
  <p>So, how should I name the .xml file that goes into the Downloads/Data folder and how should it it look inside?</p>