﻿<?xml version="1.0"?>
<!DOCTYPE xml [
  <!ELEMENT xml (transactions)>
    <!ATTLIST xml ignored (-1|0) "0">
    <!ELEMENT transactions (transaction)+>
      <!ELEMENT transaction (document|notification|list|serial_number|bom)+>
        <!ATTLIST transaction type (wf_import_document_attributes|import_notifications|import_lists|import_serial_numbers) #REQUIRED>
        <!ATTLIST transaction date CDATA #REQUIRED>       <!-- Seconds since 1 Jan 1970 00:00 -->
        <!ATTLIST transaction ignored (-1|0) "0">
        <!ATTLIST transaction vaultname CDATA #REQUIRED>

      <!ELEMENT document (configuration*)>
        <!ATTLIST document aliasset CDATA "">             <!-- The name of an alias set to use when looking up the name of the children attribute nodes. May be "". No newlines allowed and name is trimmed. -->
        <!ATTLIST document id CDATA #REQUIRED>            <!-- A value (newlines kept, trailin/leading spaces are not trimmed) that we use for finding matching documents. The value is looked up for the (optional) configuration and variable name given in "idattribute" in table VariableValue. -->
        <!ATTLIST document idattribute CDATA #REQUIRED>   <!-- An existing variable name that is used to match the "id" with -->
        <!ATTLIST document idcfgname CDATA "">            <!-- Configuration name we use when looking up documents that match "id". Empty means any configuration -->
        <!ATTLIST document pdmweid CDATA "0">             <!-- The internal DocumentID of PDMWE. Import: If >0 [id],[idattribute],[idcfgname] are ignored. -->
          <!ELEMENT configuration (attribute*, references*, whereused*)>
            <!ATTLIST configuration name CDATA "">        <!-- Name of the configuration. May be empty for files without configurations. For import empty means "all". -->
            <!ATTLIST configuration active (-1|0) "0">    <!-- Is the configuration referring to the active one? -->
            <!ATTLIST configuration quantity CDATA "0" >   <!-- The quantity (double precision) of this document. Ignored during import. Exported if "Show quantity" option is set for the export script. -->
            <!ELEMENT attribute EMPTY>
              <!ATTLIST attribute name CDATA #REQUIRED>
              <!ATTLIST attribute value CDATA #REQUIRED>
            <!ELEMENT references (document)*>
            <!ELEMENT whereused (document)*>
          
      <!ELEMENT bom (bomheader|bomrow+)>        <!-- Only used when exporting table style BOMs -->
        <!ATTLIST bom name CDATA "">
        <!ATTLIST bom id CDATA "">
        <!ATTLIST bom path CDATA "">
        <!ATTLIST bom document_id CDATA #REQUIRED>
        <!ATTLIST bom document_path CDATA #REQUIRED>
        <!ATTLIST bom type CDATA #REQUIRED>
        <!ATTLIST bom config_id CDATA "">
        <!ATTLIST bom config_name CDATA "">    
          <!ELEMENT bomheader (bomcol+)>
            <!ELEMENT bomcol EMPTY>
              <!ATTLIST bomcol col_no CDATA #REQUIRED>
              <!ATTLIST bomcol name CDATA #REQUIRED>
              <!ATTLIST bomcol alignment CDATA "">
          <!ELEMENT bomrow (bomcell+)>
            <!ATTLIST bomrow row_no CDATA "">
            <!ATTLIST bomrow document_id CDATA "">
            <!ATTLIST bomrow path CDATA "">
              <!ELEMENT bomcell EMPTY>
                <!ATTLIST bomcell col_no CDATA #REQUIRED>
                <!ATTLIST bomcell value CDATA #REQUIRED>
  
      <!ELEMENT notification (recipient+)>
        <!ATTLIST notification sender CDATA #REQUIRED>
        <!ATTLIST notification subject CDATA #REQUIRED>
        <!ATTLIST notification message CDATA #REQUIRED>
        <!ELEMENT recipient EMPTY>
          <!ATTLIST recipient user_login CDATA "">
          <!ATTLIST recipient user_name CDATA "">
          <!ATTLIST recipient group_name CDATA "">

      <!ELEMENT list (item+,link*)>
        <!ATTLIST list name CDATA #REQUIRED>
        <!ELEMENT item EMPTY>
          <!ATTLIST item item_name CDATA #REQUIRED>
        <!ELEMENT link EMPTY>
          <!ATTLIST link source_variable CDATA #REQUIRED>
          <!ATTLIST link list_variable CDATA #REQUIRED>
          <!ATTLIST link link_value CDATA #REQUIRED>

      <!ELEMENT serial_number (serno_item+)>
        <!ATTLIST serial_number name CDATA #REQUIRED>
        <!ATTLIST serial_number mode (append|replace) "replace">
        <!ELEMENT serno_item EMPTY>
        <!ATTLIST serno_item item_value CDATA #REQUIRED>
          <!ATTLIST serno_item item_counter CDATA #REQUIRED>
]>
<!--To use the dtd in an external file: <!DOCTYPE xml SYSTEM "filename.dtd">-->

<xml>
  <transactions>
    <transaction type="wf_import_document_attributes" date="123456" vaultname="VaultName">
      <document id="4" aliasset="SetDocFiles" idattribute="Assembly No.">
        <configuration name="">
          <attribute name="ManagerAlias" value="Pelle" /> <!-- alias -->
          <attribute name="Material" value="Wood" /> <!-- variable -->
          <attribute name="WeightAlias" value="83.45" /> <!-- alias -->
          <references>
            <document id="5" aliasset="SetDocFiles" idattribute="Assembly No."> <!-- Ignored because it is empty, it doesn't matter if it exists in Db or not -->
            </document>
          </references>
          <whereused>
            <document id="3" aliasset="SetDocFiles" idattribute="Assembly No.">
              <configuration name="">
                <attribute name="Approved By" value="Jalle" />
                <references>
                  <document id="4" aliasset="SetDocFiles" idattribute="Assembly No."> <!-- Cyclic reference -->
                    <configuration name="">
                      <attribute name="Material" value="WoodOnFire" /> <!-- Shouldn't really happen because it's the same doc that has Wood, in the same transaction. So the resulting value is depending on the order in the xml-file -->
                    </configuration>
                  </document>
                </references>
              </configuration>
            </document>
          </whereused>
        </configuration>
      </document>
      <document id="4" aliasset="SetDocFiles" idattribute="Assembly No.">
        <!-- <attribute name="ConstructedBy" value="Pelle" /> --> <!-- use of attribute is not supported -->
        <!-- empty document should not be saved in the updated xml file -->
      </document>
    </transaction>
    <transaction type="wf_import_document_attributes" date="123457" vaultname="VaultName">
      <document id="4" aliasset="SetDocFiles" idattribute="Assembly No.">
        <configuration name="">
          <attribute name="ManagerAlias" value="Kalle" /> <!-- alias, should overwrite previous Pelle value-->
        </configuration>
      </document>
    </transaction>
    
    <transaction type="wf_import_document_attributes" date="123458" vaultname="VaultName">
      <document id="4" aliasset="SetDocFiles" idattribute="NoSuchID"> <!-- This attribute does not exist so this should remain in file and ignore-attribute should be added for the xml-tag -->
        <configuration name="">
          <attribute name="ManagerAlias" value="KalleNotCommitedToDb" /> 
        </configuration>
      </document>
    </transaction>

   
  </transactions>
</xml>


