Hi all,
My apologies if this is a bit long winded...
I have an issue here that I hope someone can help with. I'm *very* new at XML... this is my third day on it
successfully created a SQLXML template file ok that reads information from a sql2000 database and outputs to IIS5 as long as only one contact is found for a particular company
xml output (with one record match) as follows:
===========================================================
- <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <customer accountno="11231" company="Company1">
- <contact Name="Foo Bar">
<Phone_Office>12345678</Phone_Office>
<Address1>27 Some Place</Address1>
<City>NEWCASTLE</City>
<State>NSW</State>
<Postcode>2300</Postcode>
</contact>
- <support>
<SuppMaint>None</SuppMaint>
<Product>Product1</Product>
<Version>1.7</Version>
</support>
</customer>
</ROOT>
===========================================================
Problem is that if more than one contact is found for that company, the entries are all messed up. output shown below:
===========================================================
- <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <customer accountno="11234" company="Company2">
- <contact Name="Person 1">
<Phone_Office>12345678</Phone_Office>
<Phone_Direct>87654321</Phone_Direct>
<Phone_Mobile>23456789</Phone_Mobile>
<Address1>1 another place</Address1>
<City>SYDNET</City>
<State>NSW</State>
<Postcode>2000</Postcode>
</contact>
- <support>
<SuppMaint>12 Months</SuppMaint>
<Product>Product2</Product>
<Version>2.2</Version>
</support>
- <support>
<SuppMaint>12 Months</SuppMaint>
<Product>Product2</Product>
<Version>2.2</Version>
</support>
- <contact Name="Person2">
<Phone_Office>12345678</Phone_Office>
<Phone_Direct>345998374/Phone_Direct>
<Phone_Mobile>004534573</Phone_Mobile>
<Address1>1 another place</Address1>
<City>SYDNEY</City>
<State>NSW</State>
<Postcode>2000</Postcode>
</contact>
</customer>
<customer accountno="11235" company="Company2" />
===========================================================
SQLXML template code is as follows:
===========================================================
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:header>
<sqlaram name="company">COMPANY</sqlaram>
</sql:header>
<sql:query>
SELECT 1 as Tag, NULL as Parent,
details.accountno as [customer!1!accountno],
details.company as [customer!1!company],
details.contact as [contact!2!Name],
NULL as [contact!2!Phone_Office!element],
NULL as [contact!2!Phone_Direct!element],
NULL as [contact!2!Phone_Mobile!element],
NULL as [contact!2!Address1!element],
NULL as [contact!2!Address2!element],
NULL as [contact!2!PO_Box!element],
NULL as [contact!2!City!element],
NULL as [contact!2!State!element],
NULL as [contact!2!Postcode!element],
NULL as [support!3!SuppMaint!element],
NULL as [support!3!Product!element],
NULL as [support!3!Version!element]
FROM contact1 details
WHERE details.company = @company
UNION ALL
SELECT 2,1,
details.accountno,
details.company,
details.contact,
details.phone1,
details.phone2,
details.phone3,
details.address1,
details.address2,
details.address3,
details.city,
details.state,
details.zip,
NULL,
NULL,
NULL
FROM contact1 details
WHERE details.company = @company
UNION ALL
SELECT 3,1,
details.accountno,
details.company,
details.contact,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
support.usppmnttyp,
support.ucustprod,
support.uversion
FROM contact1 details, contact2 support
WHERE details.company = @company AND details.accountno = support.accountno
ORDER BY [customer!1!accountno]
For XML EXPLICIT
</sql:query>
</ROOT>
===========================================================
If anyone can tell me where I've gone wrong, or a better way to write this XML, please let me know. Thanks in advance.
My apologies if this is a bit long winded...
I have an issue here that I hope someone can help with. I'm *very* new at XML... this is my third day on it
successfully created a SQLXML template file ok that reads information from a sql2000 database and outputs to IIS5 as long as only one contact is found for a particular company
xml output (with one record match) as follows:
===========================================================
- <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <customer accountno="11231" company="Company1">
- <contact Name="Foo Bar">
<Phone_Office>12345678</Phone_Office>
<Address1>27 Some Place</Address1>
<City>NEWCASTLE</City>
<State>NSW</State>
<Postcode>2300</Postcode>
</contact>
- <support>
<SuppMaint>None</SuppMaint>
<Product>Product1</Product>
<Version>1.7</Version>
</support>
</customer>
</ROOT>
===========================================================
Problem is that if more than one contact is found for that company, the entries are all messed up. output shown below:
===========================================================
- <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
- <customer accountno="11234" company="Company2">
- <contact Name="Person 1">
<Phone_Office>12345678</Phone_Office>
<Phone_Direct>87654321</Phone_Direct>
<Phone_Mobile>23456789</Phone_Mobile>
<Address1>1 another place</Address1>
<City>SYDNET</City>
<State>NSW</State>
<Postcode>2000</Postcode>
</contact>
- <support>
<SuppMaint>12 Months</SuppMaint>
<Product>Product2</Product>
<Version>2.2</Version>
</support>
- <support>
<SuppMaint>12 Months</SuppMaint>
<Product>Product2</Product>
<Version>2.2</Version>
</support>
- <contact Name="Person2">
<Phone_Office>12345678</Phone_Office>
<Phone_Direct>345998374/Phone_Direct>
<Phone_Mobile>004534573</Phone_Mobile>
<Address1>1 another place</Address1>
<City>SYDNEY</City>
<State>NSW</State>
<Postcode>2000</Postcode>
</contact>
</customer>
<customer accountno="11235" company="Company2" />
===========================================================
SQLXML template code is as follows:
===========================================================
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:header>
<sqlaram name="company">COMPANY</sqlaram>
</sql:header>
<sql:query>
SELECT 1 as Tag, NULL as Parent,
details.accountno as [customer!1!accountno],
details.company as [customer!1!company],
details.contact as [contact!2!Name],
NULL as [contact!2!Phone_Office!element],
NULL as [contact!2!Phone_Direct!element],
NULL as [contact!2!Phone_Mobile!element],
NULL as [contact!2!Address1!element],
NULL as [contact!2!Address2!element],
NULL as [contact!2!PO_Box!element],
NULL as [contact!2!City!element],
NULL as [contact!2!State!element],
NULL as [contact!2!Postcode!element],
NULL as [support!3!SuppMaint!element],
NULL as [support!3!Product!element],
NULL as [support!3!Version!element]
FROM contact1 details
WHERE details.company = @company
UNION ALL
SELECT 2,1,
details.accountno,
details.company,
details.contact,
details.phone1,
details.phone2,
details.phone3,
details.address1,
details.address2,
details.address3,
details.city,
details.state,
details.zip,
NULL,
NULL,
NULL
FROM contact1 details
WHERE details.company = @company
UNION ALL
SELECT 3,1,
details.accountno,
details.company,
details.contact,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
support.usppmnttyp,
support.ucustprod,
support.uversion
FROM contact1 details, contact2 support
WHERE details.company = @company AND details.accountno = support.accountno
ORDER BY [customer!1!accountno]
For XML EXPLICIT
</sql:query>
</ROOT>
===========================================================
If anyone can tell me where I've gone wrong, or a better way to write this XML, please let me know. Thanks in advance.