<TIMPORT> from an XML file error message

Post Reply
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

<TIMPORT> from an XML file error message

Post by source1ben »

I am trying to use <timport> to import data from an XML file into Texis. I have multiple levels of element to deal with. I can get it to successfully import the first <list> element into my table (and everything within it), but then I get a error when it trys to import the next <list> element.

Here is the error.
<!-- 000 preprocessxml:67: texis ABEND exception 0xC0000005 (ACCESS_VIOLATION) -->

Here is my code.

<$xml_file="c:\filename.xml">
<timport row 'recexpr >><Public>=!</Public>+</Public>
field Public varchar 1
field Publicdata varchar 2
' $xml_file>
<timport row 'recexpr >><list>=!</list>+</list>
field list varchar 1
field listdata varchar 2
' $Publicdata>
<timport row 'recexpr >><listname>=!</listname>*</listname>
field listname varchar 2
' $listdata>
<timport row 'recexpr >><listid>=!</listid>*</listid>
field listid varchar 2
' $listdata>
<timport row 'recexpr >><search>=!</search>+</search>
field search varchar 1
field searchdata varchar 2
' $listdata>
<timport row 'recexpr >><searchname>=!</searchname>*</searchname>
field searchname varchar 2
' $searchdata>
<timport row 'recexpr >><SearchTerms>=!</SearchTerms>*</SearchTerms>
field SearchTerms varchar 2
' $searchdata>
<sql "insert into searchtermdly values
(counter,$listname,$listid,$searchname,$SearchTerms)"></sql>
</timport>
</timport>
</timport>
</timport>
</timport>
</timport>
</timport>


Here is my XML file.


<?xml version="1.0" encoding="UTF-8" ?>
- <Public>
- <list>
<listname>susu</listname>
<listid>2237</listid>
- <search>
<searchname>ChangC4</searchname>
<SearchTerms>'"pick up stix"'</SearchTerms>
</search>
- <search>
<searchname>culinaryC</searchname>
<SearchTerms>('"culinary institute of america"' or '"food and beverage institute"')</SearchTerms>
</search>
- <search>
<searchname>OfficialC</searchname>
<SearchTerms>('"official payment"' or '"phonecharge inc"' or 'opay' or '"official payments"')</SearchTerms>
</search>
</list>
- <list>
<listname>susu2</listname>
<listid>2245</listid>
- <search>
<searchname>SaltC</searchname>
<SearchTerms>('deicing' or '"salt truck"' or '"salt trucks"')</SearchTerms>
</search>
- <search>
<searchname>SaltC2</searchname>
<SearchTerms>'salt' and 'sand' and not '"salt lake"'</SearchTerms>
</search>
- <search>
</list>
</Public>

Any Ideas?

thx.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

<TIMPORT> from an XML file error message

Post by mark »

Timport doesn't like to be nested more than 4 deep. Your application doesn't really call for timport anyhow since you only have single subexpressions you need for each match. Use rex instead.

<rex row ">><Public>\P=!</Public>+\F</Public>">
<$Publicdata=$ret>
<rex row ">><list>\P=!</list>+\P</list>">
<$listdata=$ret>
...
</rex>
</rex>
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

<TIMPORT> from an XML file error message

Post by source1ben »

Worked like a charm after I added the $xml_file variable to the end of the <rex> finction.

<rex row ">><Public>\P=!</Public>+\F</Public>" $xml_file>
<$Publicdata=$ret>
<rex row ">><list>\P=!</list>+\P</list>" $Publicdata>
<$listdata=$ret>
...
</rex>
</rex>

thx.

Ben
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

<TIMPORT> from an XML file error message

Post by mark »

oops, sorry.
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

<TIMPORT> from an XML file error message

Post by source1ben »

Ok - back to the drawing board. Now I need to do just the opposite. I want to dump the data (with ability to add a criteria - ie. ) from a table to an XML file.

Here is my effort.

<sql output=xml "select column1, column2 from table">
<write append "/data/myfile.xml">
<fmt "%s\r\n" "<allmydata>">
<fmt "%s\r\n" "<subdata>">
<fmt "%s\r\n" $column1>
<fmt "%s\r\n" $column2>
<fmt "%s\r\n" "</subdata>">
<fmt "%s\r\n" "</allmydata>">
</write>
</sql>

Few things.

Do I need to add the <elements> $column1 </elements> manually OR is there a way to assign the column names into the element name?

I am getting output back to the screen (from command line) - Is there a way to turn this off?

How would I group the items? For example.

<allmydata>
<subdata>
<column1>address field stuff</column1>
<column2>data goes here1</column2>
</subdata>
<subdata>
<column1>address field stuff2</column1>
<column2>data goes here3</column2>
</subdata>
</allmydata>

Can the powerful REX save me again?

Sorry for so many the questions, but I'm lost (again).

thx.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

<TIMPORT> from an XML file error message

Post by mark »

If you're using output=xml you shouldn't need to construct any per-record xml at all. If not you need to output all of the xml info.
In either case your sql loop should be inside the alldata, not outside.
You should experiment with unadorned output to see exactly what output=xml generates.

Here's how you might do it with no help from output=xml

<write "/data/myfile.xml">
<fmt "%s\r\n" "<allmydata>">
<sql "select column1, column2 from table">
<fmt "%s\r\n" "<subdata>">
<fmt "%s\r\n" $column1>
<fmt "%s\r\n" $column2>
<fmt "%s\r\n" "</subdata>">
</sql>
<fmt "%s\r\n" "</allmydata>">
</write>
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

<TIMPORT> from an XML file error message

Post by source1ben »

I got it to work !

thx.
Post Reply