Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsql-error -- Unexpected EOF 1

Status
Not open for further replies.

DairylandDan

Programmer
Apr 3, 2008
17
US
Hey hey! I'm back, and asking for more assistance! <groan>

OK, I'm on AIX trying to extract data from an xml document and insert it into an Oracle 10g sid.

But, rather than look at my real data, let's look at the classic books xml example.

Here's the xml:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<book ID="BN002" version="final">
 <author ID="A0001">kvattem</author>
 <title>Oracle XDK</title>
 <price>50</price>
</book>

Here's the db:
Code:
CREATE TABLE BOOK (
     ID VARCHAR2(80),
     VERSION VARCHAR2(80),
     AUTHORID VARCHAR2(80),
     TITLE VARCHAR2(80),
     PRICE NUMBER
     );

Here's the xsl:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]

<!-- insert-book.xsl -->
<ROWSET xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xsl:version="1.0">
 <xsl:for-each select="//book">
  <ROW>
   <ID><xsl:value-of select="@ID"/></ID>
   <VERSION><xsl:value-of select="@version"/></VERSION>
   <!-- We're ignoring the author, just getting the author's id -->
   <AUTHORID><xsl:value-of select="author/@id"/></AUTHORID>
   <TITLE><xsl:value-of select="title" /></TITLE>
   <PRICE><xsl:value-of select="price"/></PRICE>
  </ROW>
 </xsl:for-each>
</ROWSET>

and here's the xsql:
Code:
<?xml version="1.0"?>

<!-- insert-book.xsql -->
 <xsql:insert-request xmlns:xsql="urn:oracle-xsql" table="BOOK" transform="insert-book.xsl" connection="testapps"/>

from the command line, when I try to invoke the xsql utility as follows:
Code:
xsql insert-book.xsql posted-xml=book.xml
   xsql-status action="xsql:insert-request" rows="1"

I get the following error:
Code:
<?xml version = '1.0'?>
<!-- insert-book.xsql -->
<xsql-error action="xsql:insert-request">
   <message>Unexpected EOF.</message>
</xsql-error>

Can anyone explain to me what I've done wrong? Thanx in advance!


DLD
 
[1] You need to close <xsl:stylesheet>. That is probably the reason reflected in the error message.

[2] You need to have every output made by the transformation from within one template or or another. Barely exposed output tag in not accepted in the xsl document.

[3] This is minor: @id is not @ID for the author.
[tt]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[ignore][/ignore]">

<!-- insert-book.xsl -->
[red]<xsl:template match="/">[/red]
<ROWSET xmlns:xsl="[ignore][/ignore]" xsl:version="1.0">
<xsl:for-each select="//book">
<ROW>
<ID><xsl:value-of select="@ID"/></ID>
<VERSION><xsl:value-of select="@version"/></VERSION>
<!-- We're ignoring the author, just getting the author's id -->
<AUTHORID><xsl:value-of select="author/@[red]ID[/red]"/></AUTHORID>
<TITLE><xsl:value-of select="title" /></TITLE>
<PRICE><xsl:value-of select="price"/></PRICE>
</ROW>
</xsl:for-each>
</ROWSET>
[red]</xsl:template>
</xsl:stylesheet>[/red]
[/tt]
 
EXCELLENT!

I implimented your suggested changes (in addition to a change of my command line call to invoke the xsql utility) and it works correctly. No EOF error!

Thanx 'tsuji', your assistance is much appreciated!



For anyone else interested to my command line call change, here's what I'm using now:

Code:
java oracle.xml.xsql.XSQLCommandLine insert-book.xsql posted-xml=book.xml xsql-status action="xsql:insert-request" rows="1"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top