[Openroad-users] Problems with XSL Transformation stylesheet

Bloomfield, Martin (PSD) Martin.Bloomfield at psd.defra.gsi.gov.uk
Tue Aug 14 18:36:55 EST 2007


Jim,

 

Thanks for pointing out the fact that the currently included files do
not validate against the specified schema.  Unfortunately, I had to
heavily edit the XML document in order to get the email accepted by the
OpenROAD relay.  The actual files we receive are fully validated against
the schema, and contain upto 100 <sample> structures, each containing
upto 200 <analyte> structures.  In our procedures, we validate the files
against the schema before loading them using the OpenROAD application,
so this is not a problem in real life.

Martin Bloomfield. 



From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Antill, Jim
Sent: Tuesday, August 14, 2007 9:22 AM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Problems with XSL Transformation
stylesheet

 

Martin,

 

>From the stuff I've done with Java the XSLT transformer definitely
should not be reliant on the document being pretty-printed.

 

However, I did notice that the XML documents in the mail don't seem to
comply with the schemas referenced by them. I got errors saying that:

 

"Unexpected element 'PartAnalysis' in element 'Sample'. Expected:
SeaArea, SampleType .

 

I would expect these errors to be picked up preferably before the
transformation occurs e.g during the loading of the document, or if not
then certainly by the XSLT transformer. If the problems aren't picked up
then the validity of the output transformation cannot be assured,
possibly leading to bigger problems.

 

Try removing the schemas (or correcting the documents) and see if that
makes any difference.

 

Hope that helps.

 

Regards,

Jim

	-----Original Message-----
	From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com]On Behalf Of Bloomfield,
Martin (PSD)
	Sent: 14 August 2007 08:23
	To: Openroad-Users
	Subject: [Openroad-users] Problems with XSL Transformation
stylesheet

	

	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
<mailto:martin.bloomfield at psd.defra.gsi.gov.uk> 
	Website: www.pesticides.gov.uk <http://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/a8212830/attachment.html 


More information about the Openroad-users mailing list