Open ROAD Users,
With previous help from this group, I have managed to create an
application that will import XML formatted files into my OpenROAD
application. This uses an XSL stylesheet to convert the XML attributes
into XML Elements so they can be converted into an OpenROAD array
attributes properly.
The problem I am having is that if the XML file is not "pretty-print"
formatted (i.e. does not have each element indented under its parent),
then nothing is created by the conversion. Has anyone else had this
problem, and if so, how did you get around this problem? Ideally, the
XSL stylesheet should be able to convert either type of file, as we
cannot guarantee how the data will be supplied to us.
Any advice would be gratefully appreciated,
Martin Bloomfield.
_________________________________________________
Application Developer & Database Administrator
IT Branch,
Pesticides Safety Directorate
YORK
Email: martin.bloomfield at psd.defra.gsi.gov.uk
Website: www.pesticides.gov.uk
Save a tree... please don't print this e-mail unless you really need to
My XSL Stylesheet is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:copy>
<xsl:if test="@*">
<xsl:for-each select="@*">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:if>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
A working XML file is:
<?xml version="1.0" encoding="UTF-8"?>
<Results xmlns="https://secure.pesticides.gov.uk/schemas/PRCResults"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://secure.pesticides.gov.uk/schemas/PRCResults
https://secure.pesticides.gov.uk/schemas/PRCResults.xsd">
<Sample SampleID="1223/2007">
<SampleCity>K</SampleCity>
<CollectorID>U</CollectorID>
<CommodityName>M</CommodityName>
<FoodName>T</FoodName>
<FoodDescription>WM</FoodDescription>
<SampledDate>2007-04-13</SampledDate>
<Organic>N</Organic>
<SampleState>F</SampleState>
<PackagingType>PC</PackagingType>
<SamplingPointName>T</SamplingPointName>
<SamplingPointAddress>H</SamplingPointAddress>
<SamplingPointPostcode>GIR 0AA</SamplingPointPostcode>
<SamplingPointType>S</SamplingPointType>
<CountryOfOrigin>UK</CountryOfOrigin>
<PartAnalysis>W</PartAnalysis>
<LabReference>H</LabReference>
<SurveyTitle>M</SurveyTitle>
<Analyte PesticideCode="A">
<Recovery>90</Recovery>
<ReportingLimit>0.002</ReportingLimit>
<SpikeValue>0.005</SpikeValue>
<Concentration>0</Concentration>
</Analyte>
</Sample>
</Results>
However, the following file does not work:
<?xml version="1.0" encoding="UTF-8"?>
<Results xmlns="https://secure.pesticides.gov.uk/schemas/PRCResults"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://secure.pesticides.gov.uk/schemas/PRCResults
https://secure.pesticides.gov.uk/schemas/PRCResults.xsd">
<Sample SampleID="1223/2007">
<SampleCity>K</SampleCity>
<CollectorID>U</CollectorID>
<CommodityName>M</CommodityName>
<FoodName>T</FoodName>
<FoodDescription>WM</FoodDescription>
<SampledDate>2007-04-13</SampledDate>
<Organic>N</Organic>
<SampleState>F</SampleState>
<PackagingType>PC</PackagingType>
<SamplingPointName>T</SamplingPointName>
<SamplingPointAddress>H</SamplingPointAddress>
<SamplingPointPostcode>GIR 0AA</SamplingPointPostcode>
<SamplingPointType>S</SamplingPointType>
<CountryOfOrigin>UK</CountryOfOrigin>
<PartAnalysis>W</PartAnalysis>
<LabReference>H</LabReference>
<SurveyTitle>M</SurveyTitle>
<Analyte PesticideCode="A">
<Recovery>90</Recovery>
<ReportingLimit>0.002</ReportingLimit>
<SpikeValue>0.005</SpikeValue>
<Concentration>0</Concentration>
</Analyte>
</Sample>
</Results>
Department for Environment, Food and Rural Affairs (Defra)
This email and any attachments is intended for the named recipient only.
If you have received it in error you have no authority to use, disclose,
store or copy any of its contents and you should destroy it and inform
the sender.
Whilst this email and associated attachments will have been checked
for known viruses whilst within Defra systems we can accept no
responsibility once it has left our systems.
Communications on Defra's computer systems may be monitored and/or
recorded to secure the effective operation of the system and for other
lawful purposes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20070814/6a9ef9f4/attachment.html