XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Bernard QuinnSubject: Illegal XML characters
Author: Bernard Quinn
Date: 14 Aug 2008 11:33 AM
I have an XQuery built which generates the XML I need from a relational db (MS SQL Server 2005). I ocassionally get an "illegal xml character" error that kills the pull. Since studio obviously recognizes the bad character, is there a way to filter them out on the fly? Shouldn't there be a simple "drop anything illegal" filter available somewhere?

Postnext
Minollo I.Subject: Illegal XML characters
Author: Minollo I.
Date: 14 Aug 2008 11:44 AM
That actually shouldn't happen; characters pulled from the database which are not valid XML characters should just get escaped by the XQuery engine.

Can you narrow down the problem and provide more details about the context in which that error is reported?

Postnext
Bernard QuinnSubject: Illegal XML characters
Author: Bernard Quinn
Date: 14 Aug 2008 11:57 AM
I'm in studio, doing an XQuery that has a fairly complex mapping implemented. For certain records, when I run the query (in preview mode), I'll get:

[DataDirect][XQuery][err:SERE0006]The character '' is an invalid XML character.

details:

com.ddtek.xquery3.XQQueryException: [DataDirect][XQuery][err:SERE0006]The character '' is an invalid XML character.

at com.ddtek.xquery3.xqj.Util.XQQueryException(Util.java:376)

at com.ddtek.xquery3.xqj.Util.XQException(Util.java:250)

at com.ddtek.xquery3.xqj.layer.DDXQAbstractSequence.writeSequence(DDXQAbstractSequence.java:431)

Caused by: com.ddtek.xquery.util.XQueryException: [SER0017][DataDirect][XQuery][err:SERE0006]The character '' is an invalid XML character.

at com.ddtek.xquery.serialize.Serializer.writeEscaped(Serializer.java:1473)

at com.ddtek.xquery.serialize.Serializer.doXMLSerialization(Serializer.java:902)

at com.ddtek.xquery.serialize.Serializer.serialize(Serializer.java:491)

at com.ddtek.xquery.serialize.Serializer.serialize(Serializer.java:473)

at com.ddtek.xquery3.xqj.layer.DDXQAbstractSequence.writeSequence(DDXQAbstractSequence.java:427)

When this happens, no output is generated, all I know is that somewhere in the 1000 records I was working on, it found something bad.

Posttop
Minollo I.Subject: Illegal XML characters
Author: Minollo I.
Date: 21 Aug 2008 01:32 PM
 is indeed an invalid XML character. And there isn't a way to instruct the XQuery engine to skip/replace invalid XML character retrieved from the database.

Since you are using SQLServer 2005, you can try the following approach:

import module namespace ddtek-sql = "http://www.datadirect.com/xquery/sql-function" at "sqlfunctions_sqlserver.xq";
for $row in collection("MYTABLE")/MYTABLE
let $col := $row/column1
let $col := ddtek-sql:REPLACE($col, ddtek-sql:CHAR(xs:int(1)), "")
return $col

The sqlfunctions_sqlserver.xq can be found in the examples/ExternalFunctions directory of your DataDirect XQuery installation (or in <stylusstudiodir>\Components\DataDirect XQuery\examples" in a typical Stylus Studio installation).

For multiple illegal characters you could do:

import module namespace ddtek-sql = "http://www.datadirect.com/xquery/sql-function" at "sqlfunctions_sqlserver.xq";
for $row in collection("MYTABLE")/MYTABLE
let $col := $row/column1
let $col := ddtek-sql:REPLACE($col, ddtek-sql:CHAR(xs:int(1)), "")
let $col := ddtek-sql:REPLACE($col, ddtek-sql:CHAR(xs:int(2)), "")
return $col

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.