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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL, transform XML to XML for MS Access

Status
Not open for further replies.

mrussell71

IS-IT--Management
Nov 28, 2001
20
0
0
US
I am trying to transform an XML file to another new XML file that will allow me to import the new file into Access. Access will not import 'attribute-centric' XML files so the new file will have to be 'element-centric'.

I have the VBA code to perform the import and it works properly. What I am missing is the proper syntax for the XSL file that is loaded as a DOMDocument(domStyleSheet) and performs the transformation.

original XML:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Part>
    <App action="A" id="0001084521637132003">
        <BaseVehicle id="5241" />
        <VehicleType id="5" />
        <SubModel id="681" />
        <EngineBase id="904" />
        <EngineVIN id="6" />
        <Qty>1</Qty>
        <PartType id="7212" />
        <!-- Spark Plug	-->
        <MfrLabel>platinum</MfrLabel>
        <DisplayOrder>1</DisplayOrder>
        <Part>AZFS32FEF4</Part>
    </App>
    <App action="A" id="0001132811700771971">
        <Make id="54" />
        <Years from="1971" to="1971" />
        <VehicleType id="5" />
        <FuelType id="6" />
        <Note>3 &amp; 4 Cyl. 2000, 3000, 4000, 5000 (Gasoline)</Note>
        <Qty>1</Qty>
        <PartType id="7212" />
        <!-- Spark Plug	-->
        <MfrLabel>copper</MfrLabel>
        <DisplayOrder>1</DisplayOrder>
        <Part>AGS4CF4</Part>
    </App>
<Part>

New XML:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Part>
     <App>
		<action>A</action>
		<id>0001084521637132003</id>
		<BaseVehicle>5241</BaseVehicle>
		<From></From>
		<To></To>
		<VehicleType>5</VehicleType> 
		<SubModel>681</SubModel> 
		<EngineBase>904</EngineBase> 
		<EngineVIN>6</EngineVIN> 
		<VehicleType></VehicleType>
		<FuelType></FuelType>
		<Note></Note>
		<Qty>1</Qty>
        <PartType>7212</PartType>
        <MfrLabel>platinum</MfrLabel>
        <DisplayOrder>1</DisplayOrder>
		<Part>AZFS32FEF4</Part>
	</App>

	<App>
		<action>A</action>
		<id>0001084521637131998</id>
		<BaseVehicle></BaseVehicle>
		<From>1971</From>
		<To>1971</To>
		<VehicleType></VehicleType> 
		<SubModel></SubModel> 
		<EngineBase></EngineBase> 
		<EngineVIN></EngineVIN> 
		<VehicleType>5</VehicleType>
		<FuelType>6</FuelType>
		<Note>3 &amp; 4 Cyl. 2000, 3000, 4000, 5000 (Gasoline)</Note>
		<Qty>1</Qty>
		<PartType>7212</PartType>
        <MfrLabel>copper</MfrLabel>
        <DisplayOrder>1</DisplayOrder>
		<Part>AGS4CF4</Part>
	</App>
</Part>

As you can see from the XML above, a record may contain elements that another record does not, therefore I will need to have empty tags in the new XML that are like placeholders.

What I need is an XSL file that will perform this transformation. I'm new to XML and XSLT, so any help is greatly appreciated.


Thanks,

Russell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top