I have a dtd from a client and I need to export our database records to an
XML doc compliant to that DTD.
My question is what's the best method to go about that?
Currently we bring all the values in from a couple different SQL statements
and pop them into variables and then format them and write them out to a CVS
file. The client now wants an XML format of the export.
Is it best to continue to pull the SQL values into variables and perform the
needed calculations and then simply write the XML doc node-by-node? I've
done that before with simpler xml docs.
Is there some way I can build a dataset from the values we get from the SQL
selects and then use exporting to get xml from there? I've never attempted
to use these methods before.
What method would be best?
The dtd follows:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT bac-invoice (invoice-header,invoice-detail,invoice-footer)+>
<!ATTLIST bac-invoice source CDATA #REQUIRED >
<!ATTLIST bac-invoice exportdate CDATA #REQUIRED >
<!ELEMENT invoice-header (inv-id,vnd-id,inv-date,recvd-date,po-id?,
inv-type?,description,special-handling?,
inv-amount,inv-tax)>
<!ELEMENT invoice-detail (detail-line+)>
<!ELEMENT invoice-footer (line-item-count)>
<!-- Invoice Header elements -->
<!ELEMENT inv-id (#PCDATA)>
<!ELEMENT vnd-id (#PCDATA)>
<!ELEMENT inv-date (#PCDATA)>
<!ELEMENT recvd-date (#PCDATA)>
<!ELEMENT po-id (#PCDATA)>
<!ELEMENT inv-amount (#PCDATA)>
<!ELEMENT inv-type (#PCDATA)>
<!ELEMENT inv-tax (#PCDATA)>
<!ELEMENT description (#PCDATA) >
<!ELEMENT special-handling (#PCDATA) >
<!ELEMENT detail-line (
lineitem-id,
property-id,
tenant?,
lease?,
unit?,
project-type?,
project-ref?,
task-stage?,
contract-element?,
seg-ref?,
development?,
tax-status?,
trx-subtype?,
fnc-code?,
item-amount,
item-tax?,
(service-from,service-to)?,
(gl-company,gl-costcenter)?,
charge-code,
above-standard,
item-description,
tax-parcel?,
tax-lot?,
tax-paymentno?,
tax-period?,
tax-year?,
(utl-uom,utl-units,utl-meter)?,
wo-number?,
wo-contract?,
wo-svc-code?,
wo-requestor?,
ap-clerk-id)
<!-- Detail Line Elements -->
<!ELEMENT lineitem-id (#PCDATA)>
<!ELEMENT property-id (#PCDATA)>
<!ELEMENT tenant (#PCDATA)>
<!ELEMENT lease (#PCDATA)>
<!ELEMENT unit (#PCDATA)>
<!ELEMENT project-type (#PCDATA)>
<!ELEMENT project-ref (#PCDATA)>
<!ELEMENT task-stage (#PCDATA) >
<!ELEMENT gl-company (#PCDATA)>
<!ELEMENT gl-costcenter (#PCDATA)>
<!ELEMENT above-standard (#PCDATA)>
<!ELEMENT charge-code (#PCDATA)>
<!ELEMENT item-description (#PCDATA)>
<!ELEMENT contract-element (#PCDATA) >
<!ELEMENT item-amount (#PCDATA) >
<!ELEMENT item-tax (#PCDATA) >
<!ELEMENT development (#PCDATA) >
<!ELEMENT fnc-code (#PCDATA) >
<!ELEMENT seg-ref (#PCDATA) >
<!ELEMENT service-from (#PCDATA) >
<!ELEMENT service-to (#PCDATA) >
<!ELEMENT tax-parcel (#PCDATA) >
<!ELEMENT tax-lot (#PCDATA) >
<!ELEMENT tax-paymentno (#PCDATA) >
<!ELEMENT tax-period (#PCDATA) >
<!ELEMENT tax-year (#PCDATA) >
<!ELEMENT tax-status (#PCDATA) >
<!-- Transaction SubType -->
<!ELEMENT trx-subtype (#PCDATA) >
<!ELEMENT utl-units (#PCDATA) >
<!ELEMENT utl-uom (#PCDATA) >
<!ELEMENT utl-meter (#PCDATA)>
<!ELEMENT wo-contract (#PCDATA) >
<!ELEMENT wo-number (#PCDATA) >
<!ELEMENT wo-requestor (#PCDATA) >
<!ELEMENT wo-svc-code (#PCDATA) >
<!ELEMENT ap-clerk-id (#PCDATA) >
<!-- Footer Elements -->
<!ELEMENT line-item-count (#PCDATA) >