Hi there,
I have a problem creating an xslt-file for the following xml-file (I left out most of the records and fields except for one record :)
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<adlibXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.adlibsoft.com/adlibXML.xsd">
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<recordList>
<artiks>
<recordnummer>1</recordnummer>
<title>Nice painting</title>
<dimension_unit>cm</dimension_unit>
<dimension_unit>cm</dimension_unit>
<dimension>hoogte</dimension>
<dimension>breedte</dimension>
<dimension_value>13,5</dimension_value>
<dimension_value>3,5</dimension_value>
<location>zaal 3</location>
</artikels>
</recordList>
I want to import this file into MS Access 2k3. As you can see, info about the dimensions of this painting are double and I want to put the dimensioninformation in a different tabel.
Every first element of a tag belongs to each other, ie "cm, hoogte, 13.5" and "cm, breedte, 3.
An article can have more than 1 dimensions. a Dimension 'depth' is als o an option.
How can i do that. I did some research and i made this XSLT-script.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<test>
<xsl:for-each select="//recordList/record">
<collect>
<recordnummer>
<xsl:value-of select="priref"/>
</recordnummer>
<objectnummer>
<xsl:value-of select="object_number"/>
</objectnummer>
<title>
<xsl:value-of select="title"/>
</title>
<xsl:for-each select="dimension[(position()]">
<properties>
<xsl:apply-templates select="recnr"/>
<xsl:apply-templates select="property"/>
<xsl:apply-templates select="waarde1"/>
</properties>
</xsl:for-each>
<xsl:template match="recnr">
<recordnummer><xsl:value-of select="record_number"/></recordnummer>
</xsl:template>
<xsl:template match="property">
<eigenschap><xsl:value-of select="dimension[(position()]"/></eigenschap>
</xsl:template>
<xsl:template match="waarde">
<waarde><xsl:value-of select="dimension_value[(position()]"/></waarde>
</xsl:template>
</collect>
</xsl:for-each>
</test>
</xsl:template>
</xsl:stylesheet>
As you can see, there is some more info here about other fields (ignore them please). I made a 'for-each' loop for the dimensionfields , but it doesn't work.
What could be a good solution for my problem?
Tia