[Openroad-users] Importing XML files into Ingres/OpenROAD

Kim Ginnerup kgi at bording.dk
Thu Nov 16 03:55:16 EST 2006


Hi Martin,

 

I have attached a small frame, that gives you an idea on how to use
msxml to make transformations inside OpenROAD.

Just import the frame into an application that has an msxml external
component.

 

I found the iixmlpreprocess a bit confusing at first myself.

But I think you can more or less copy paste the code from the frame
sample.

 

How your class hierarchy should be is a little more tricky. 

OpenROAD do not make the xml output as I would have expected at first.

OpenROAD do not make an xml element around an array, it just dumps the
elements.

So sometimes you will need to have an extra class as a wrapper for an
array.

So the best way to figure out how to do, is to make your classes or some
of them from the top down.

Then put some testdata into them and let our generated xml reader/writer
generate the xml output  file.

OpenROAD will use the procedure name as the root-tag of the xml file.

 

One thing to be aware of is that OpenROAD do not generate the top
Processing Instructtion; setting the correct characterset.

Also OpenROAD automatically generates an internal dtd.

Normally I use the iixmlpostprocess() procedure,

To add the top PI, and remove the dtd.

I do that just be manipulating the stringObject.

 

In your xml example below, the Results tag would have been you gscp name
in OpenROAD

Again you can simply remove that in the preprocess, if you do not like
it.

To get the below output your parameter to the procedure would be an
"array of sample"

 

As said the best way is to put some test data into your class hierarchy
and then see what comes out of it.

What comes out is what your system expects to receive.

 

Regards,

 

Kim

 

 

________________________________

Fra: Bloomfield, Martin (PSD)
[mailto:Martin.Bloomfield at psd.defra.gsi.gov.uk] 
Sendt: 15. november 2006 15:39
Til: Kim Ginnerup
Cc: Openroad-Users
Emne: RE: [Openroad-users] Importing XML files into Ingres/OpenROAD

 

Kim,

 

Sorry to bother you again.  Thanks for the XSL transformation code.
I've tested it in XML-spy and it works fine.  However, I'm struggling to
work out how to do this in OpenROAD.  I've created myself an external
class pointing to the MSXML 4 control.  Unfortunately, not having used
external controls before, I'm rather lost as to how to put the XSL code
into the control and get it to process the b_so_preprocessxml parameter
in the iixmlpreprocess procedure.

 

Would it be possible for you to send me sample code detailing how to use
the external control, or an export of the procedure?  Also, when I
create my own "ReadFile" procedure should the class I pass to it map to
the root element of the XML file? Also, how should I name array
attributes which correspond to repeatable complex XML elements?

 

for info my XML doc has following structure:

<Results>                               <-- Do I pass the UserClass
"Results" to my procedure at this level? -->

   <sample SampleId="0001/2006">        <-- Should this be an ARRAY of
Sample in UserClass "Results"? -->

      <item1>item1</item1>

      <item2>data</item2>

      <residue Code="ABC">              <-- Should this be an ARRAY of
Residue in UserClass "Sample"? -->

         <detection>1.2</detection>

         <limit>1.0</limit>

      </residue>

      <residue Code="DEF">

         <detection>1.4</detection>

         <limit>0.5</limit>

      </residue>

   </sample>

   <sample SampleId="0002/2006">

      <item1>item2</item1>

      <item2>data2</item2>

      <residue Code="ABC">

         <detection>1.2</detection>

         <limit>1.0</limit>

      </residue>

      <residue Code="DEF">

         <detection>1.4</detection>

         <limit>0.5</limit>

      </residue>

   </sample>

</Results>

 

Many thanks for your assistance,

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/>  

	-----Original Message-----
	From: Kim Ginnerup [mailto:kgi at bording.dk] 
	Sent: Tuesday, November 14, 2006 11:48 AM
	To: Bloomfield, Martin (PSD)
	Cc: openroad-users at peerlessit.com
	Subject: SV: [Openroad-users] Importing XML files into
Ingres/OpenROAD

	Martin,

	 

	And here it is:

	 

	<?xml version="1.0" encoding="ISO-8859-1"?>

	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

	 <xsl:output method="xml" version="1.0" encoding="ISO-8859-1"
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

	 

	 

	 

	Regards,

	 

	Kim

	
________________________________


	Fra: Bloomfield, Martin (PSD)
[mailto:Martin.Bloomfield at psd.defra.gsi.gov.uk] 
	Sendt: 14. november 2006 11:29
	Til: Kim Ginnerup
	Emne: RE: [Openroad-users] Importing XML files into
Ingres/OpenROAD

	 

	Kim,

	 

	As I am new to XML, I would be extremely grateful if you are
able to send me the XSL script, as in my attempts to create an XSD, I've
discovered that unique rules only seem to work on attributes, so have
had to put the unique identifiers into attributes.  Obviously, I need to
import these into the database, so will need to convert them to
elements.

	 

	Many thanks,

	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/>  

		-----Original Message-----
		From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Kim Ginnerup
		Sent: Tuesday, November 14, 2006 5:31 AM
		To: openroad-users at peerlessit.com
		Subject: Re: [Openroad-users] Importing XML files into
Ingres/OpenROAD

		I forgot to mention

		OpenROAD only reads elements from an xml-file all
attributes are ignored.

		But you can make a very simple generic XSL-script that
change all attributes to elements.

		Put that transformation into iixmlpreprocess using
msxml.

		 

		I have such a script somewhere if you are interested I
think it is less than 10 lines of xsl.

		 

		Kim

		 

	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://peerlessit.com/pipermail/openroad-users/attachments/20061115/018e8122/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transform.exp
Type: application/octet-stream
Size: 57512 bytes
Desc: transform.exp
Url : http://peerlessit.com/pipermail/openroad-users/attachments/20061115/018e8122/attachment-0001.obj 


More information about the Openroad-users mailing list