Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL to tranform to another wellformed XML Doc ?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I would normal keep reading to creat this myself but I am pressed for time. Scenario : an object with a ToXML method that is not returning and easy to work with XML doc. I am trying to create a XSL template to transform this into another XML structure to import into SQL2K.

If anybody would give me a swift kick to get me going I would appreciate it. I already have one in place but I am having trouble to design the XLS template to return the fields in an element vs attribute.

here is a portion:

<?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?><appconn><recordset><metadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;14&quot; name=&quot;REFER&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;23&quot; name=&quot;PART&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;7&quot; name=&quot;OH&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;5&quot; name=&quot;QO&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;5&quot; name=&quot;QS&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata><fieldmetadata iskey=&quot;false&quot; isreadable=&quot;true&quot; iswriteable=&quot;false&quot; length=&quot;26&quot; name=&quot;CUST&quot; terminalattributesenabled=&quot;false&quot; type=&quot;field&quot;><description/></fieldmetadata></metadata><records><modelrecord index=&quot;1&quot;><field name=&quot;REFER&quot;>168455X3</field><field name=&quot;PART&quot;>SHA*400-1*</field><field name=&quot;OH&quot;>0</field><field name=&quot;QO&quot;>1</field><field name=&quot;QS&quot;>0</field><field name=&quot;CUST&quot;>80693</field></modelrecord><modelrecord index=&quot;2&quot;><field name=&quot;REFER&quot;>168455X3</field><field name=&quot;PART&quot;>TRIP*4106*</field><field name=&quot;OH&quot;>0</field><field name=&quot;QO&quot;>1</field><field name=&quot;QS&quot;>0</field><field name=&quot;CUST&quot;>80693</field></modelrecord></records></recordset></appconn>


Basically looking to create another XML structure with
<recordset>
<record index=&quot;1&quot;>
<REFER></REFER>
<PART></PART>
<OH></OH>
<QO></QO>
<QS></QS>
<CUST></CUST>
</record>
</recordset>

I would highly appreciate any help!!
 
I think this will help get you going in the right direction:

<?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:eek:utput method=&quot;xml&quot; indent=&quot;yes&quot;/>
<xsl:preserve-space elements=&quot;*&quot;/>

<xsl:template match=&quot;/&quot;>
<recordset>
<xsl:for-each select=&quot;//modelrecord&quot;>
<record><xsl:attribute name=&quot;index&quot;><xsl:value-of select=&quot;@index&quot;/></xsl:attribute>
<REFER>
<xsl:value-of select=&quot;field[@name='REFER']&quot; />
</REFER>
<!-- Put your other values in the same way as above -->
</record>
</xsl:for-each>
</recordset>
</xsl:template>
</xsl:stylesheet>
 
Thanks a lot for the info!!

<xsl:value-of select=&quot;field[@name='REFER']&quot; />
Exactly what I was looking for.!

Thanks Again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top