Wednesday, March 28, 2012
Invalid XML Elements found inside cync block
updategram using SQL 2005 and SQLXML 4.0
FrostingModel.Tests.Artist.InvalidConcurrencyUpdate :
Microsoft.Data.SqlXml.SqlXmlException : HRESULT="0x80004005"
Description="Invalid XML elements found inside sync block"
Here is my updategram.
<u>
<updg:sync mapping-schema=".\Schemata\Artist.xsd" nullvalue="NULL"
xmlns:updg="urn:schemas-microsoft-com:xml-updategram">
<updg:before>
<ns1:Artist updg:id="0" ArtistID="1716"
UpdateStamp="AAAAAAAADUw=" xmlns:ns1="urn:Frosting" />
</updg:before>
<updg:after>
<ns1:Artist updg:id="0" ArtistID="1716" Name="Blah Blah Update"
xmlns:ns1="urn:Frosting" />
</updg:after>
</updg:sync>
</u>
And here is the accompanying schema:
<xsd:complexType name="Artist">
<xsd:attribute name="ArtistID" type="xsd:int" use="required"
sql:identity="ignore" sql:datatype="int" />
<xsd:attribute name="Name" type="xsd:string" use="optional"
sql:datatype="nvarchar" />
<xsd:attribute name="UpdateStamp" use="optional" dt:type="bin.hex"
sql:datatype="timestamp" sql2:concurrency="UseValue" />
</xsd:complexType>
It should be noted that if I use concurrency on the Name attribute, it
works as expected. However I would prefer to use a timestamp - it's
the timestamp that seems to be the big proverbial pain in the arse.
I can't seem to find any solutions online regarding this problem... any
takers?
- ryan.Okay...
I changed my UpdateStamp value to be something like 0x000000000000101A
and the updategram worked as expected. However this doesn't make any
sense, because SQL 2005's FOR XML EXPLICIT returns the timestamp value
in a 12 character format such as "AAAAAAAADUw=", not in the above
format.
Am I missing something, or is this a bug in SQLXML 4.0 / SQL 2005? How
is it that SQL 2005 can emit a timestamp value in that "AAA..." format,
but it can't accept it? Do I have to do some type of conversion on my
client side after I receive the timestamp value from sql server?
Any help would be appreciated,
- cranley
cranley wrote:
> I'm receiving the following error when attempting to execute an
> updategram using SQL 2005 and SQLXML 4.0
> FrostingModel.Tests.Artist.InvalidConcurrencyUpdate :
> Microsoft.Data.SqlXml.SqlXmlException : HRESULT="0x80004005"
> Description="Invalid XML elements found inside sync block"
> Here is my updategram.
> <u>
> <updg:sync mapping-schema=".\Schemata\Artist.xsd" nullvalue="NULL"
> xmlns:updg="urn:schemas-microsoft-com:xml-updategram">
> <updg:before>
> <ns1:Artist updg:id="0" ArtistID="1716"
> UpdateStamp="AAAAAAAADUw=" xmlns:ns1="urn:Frosting" />
> </updg:before>
> <updg:after>
> <ns1:Artist updg:id="0" ArtistID="1716" Name="Blah Blah Update"
> xmlns:ns1="urn:Frosting" />
> </updg:after>
> </updg:sync>
> </u>
> And here is the accompanying schema:
> <xsd:complexType name="Artist">
> <xsd:attribute name="ArtistID" type="xsd:int" use="required"
> sql:identity="ignore" sql:datatype="int" />
> <xsd:attribute name="Name" type="xsd:string" use="optional"
> sql:datatype="nvarchar" />
> <xsd:attribute name="UpdateStamp" use="optional" dt:type="bin.hex"
> sql:datatype="timestamp" sql2:concurrency="UseValue" />
> </xsd:complexType>
> It should be noted that if I use concurrency on the Name attribute, it
> works as expected. However I would prefer to use a timestamp - it's
> the timestamp that seems to be the big proverbial pain in the arse.
> I can't seem to find any solutions online regarding this problem... any
> takers?
> - ryan.
Friday, March 9, 2012
invalid character when I browse Reports
=> Web Sites
=> Reports
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error
and then click the Refresh button, or try again later.
----
A name was started with an invalid character. Error processing
resource 'http://localhost/Reports/'. Line 1, Position 2
<%@. Page language="c#" Codebehind="Home.aspx.cs"
AutoEventWireup="false"
Inherits="Microsoft.ReportingServices.UI.HomePag...
When I go to inetmgr
=> Web Sites
=> ReportServer
Reporting Services Error
----
The report server has encountered a configuration error. See the
report server log files for more information.
(rsServerConfigurationError)
Access to the path 'C:\Program Files\Microsoft SQL Server\MSSQL.
3\Reporting Services\ReportServer\RSReportServer.config' is denied.
----
SQL Server Reporting Services
Any ideas welcome,
BryanThis is a wild guess but check and make sure that the Reports and
ReportServer websites in IIS are setup for the correct version of the dotnet
framework. For RS 2000 it should be 1.1 for RS 2005 it needs to be 2.0.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"dba" <bryanmurtha@.gmail.com> wrote in message
news:1193425095.280637.260080@.d55g2000hsg.googlegroups.com...
> When I go to inetmgr
> => Web Sites
> => Reports
> The XML page cannot be displayed
> Cannot view XML input using XSL style sheet. Please correct the error
> and then click the Refresh button, or try again later.
>
> ----
> A name was started with an invalid character. Error processing
> resource 'http://localhost/Reports/'. Line 1, Position 2
> <%@. Page language="c#" Codebehind="Home.aspx.cs"
> AutoEventWireup="false"
> Inherits="Microsoft.ReportingServices.UI.HomePag...
> When I go to inetmgr
> => Web Sites
> => ReportServer
> Reporting Services Error
> ----
> The report server has encountered a configuration error. See the
> report server log files for more information.
> (rsServerConfigurationError)
> Access to the path 'C:\Program Files\Microsoft SQL Server\MSSQL.
> 3\Reporting Services\ReportServer\RSReportServer.config' is denied.
> ----
> SQL Server Reporting Services
> Any ideas welcome,
> Bryan
>
Invalid character in XML
characters. While I'm reading in the data I get an error. Other than
removing the characters before the data is inserted into the database, is
there a way to handle (or omit) reading the invalid characters?
Thanks.Steve,
Have you thought about escaping the invalid characters? You can escape using
either &<decimal>; or &x<hexadecimal>;
Thanks,
Amol
"SteveISOA" wrote:
> I'm using XML EXPLICIT to query some data which may contain some invalid X
ML
> characters. While I'm reading in the data I get an error. Other than
> removing the characters before the data is inserted into the database, is
> there a way to handle (or omit) reading the invalid characters?
> Thanks.|||Amol,
At what point can you escape the invalid characters? I do not want to
modify the existing data in the database, and I'm using a very simple proces
s
of reading and writing the data. It looks something like this:
...
SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
...
XmlTextWriter txtWriter = new XmlTextWriter(...);
XmlReader xmlReader = mCommand.ExecuteXmlReader();
while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
{
txtWriter.WriteNode(xmlReader,false);
}
...
Thanks again.
Steve
"Amol Kher" wrote:
> Steve,
> Have you thought about escaping the invalid characters? You can escape usi
ng
> either &<decimal>; or &x<hexadecimal>;
> Thanks,
> Amol
> "SteveISOA" wrote:
>|||Steve,
The escaping should happen before the reader is created. But looks like you
dont have control over the reader creation. Once the reader is created, it
will work off the stream and if you can somehow intercept this stream then
you can replace it there.
Unfortunately invalid characters in XML is not allowed by the XML Spec so
the best solution is if you can fix it when the data gets in and not when yo
u
pull it out. Even if you find a solution to work around this issue,
potentially this is a compatibility issue with other compliant parsers.
Thanks,
Amol
"SteveISOA" wrote:
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple proc
ess
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>|||You need to ensure that all binary columns or char columns which has invalid
char values like 0xa, 0xb are binary encoded with encodings like binbase64.
--
Bertan ARI
This posting is provided "AS IS" with no warranties, and confers no rights.
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>|||Assuming that the characters are invalid not because of the wrong encoding
(FOR XML results are UTF-16 encoded which means that you need to set it
accordingly on the client side), you have to filter the invalid characters
out in your TSQL code. There may be some non-standard option on the XML
parser that allows you to parse the invalid characters in System.XML, but I
am not sure about that.
Best regards
Michael
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
>
Invalid character in XML
characters. While I'm reading in the data I get an error. Other than
removing the characters before the data is inserted into the database, is
there a way to handle (or omit) reading the invalid characters?
Thanks.
Steve,
Have you thought about escaping the invalid characters? You can escape using
either &<decimal>; or &x<hexadecimal>;
Thanks,
Amol
"SteveISOA" wrote:
> I'm using XML EXPLICIT to query some data which may contain some invalid XML
> characters. While I'm reading in the data I get an error. Other than
> removing the characters before the data is inserted into the database, is
> there a way to handle (or omit) reading the invalid characters?
> Thanks.
|||Amol,
At what point can you escape the invalid characters? I do not want to
modify the existing data in the database, and I'm using a very simple process
of reading and writing the data. It looks something like this:
...
SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
...
XmlTextWriter txtWriter = new XmlTextWriter(...);
XmlReader xmlReader = mCommand.ExecuteXmlReader();
while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
{
txtWriter.WriteNode(xmlReader,false);
}
...
Thanks again.
Steve
"Amol Kher" wrote:
[vbcol=seagreen]
> Steve,
> Have you thought about escaping the invalid characters? You can escape using
> either &<decimal>; or &x<hexadecimal>;
> Thanks,
> Amol
> "SteveISOA" wrote:
|||Steve,
The escaping should happen before the reader is created. But looks like you
dont have control over the reader creation. Once the reader is created, it
will work off the stream and if you can somehow intercept this stream then
you can replace it there.
Unfortunately invalid characters in XML is not allowed by the XML Spec so
the best solution is if you can fix it when the data gets in and not when you
pull it out. Even if you find a solution to work around this issue,
potentially this is a compatibility issue with other compliant parsers.
Thanks,
Amol
"SteveISOA" wrote:
[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
|||You need to ensure that all binary columns or char columns which has invalid
char values like 0xa, 0xb are binary encoded with encodings like binbase64.
Bertan ARI
This posting is provided "AS IS" with no warranties, and confers no rights.
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
|||Assuming that the characters are invalid not because of the wrong encoding
(FOR XML results are UTF-16 encoded which means that you need to set it
accordingly on the client side), you have to filter the invalid characters
out in your TSQL code. There may be some non-standard option on the XML
parser that allows you to parse the invalid characters in System.XML, but I
am not sure about that.
Best regards
Michael
"SteveISOA" <SteveISOA@.discussions.microsoft.com> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@.microsoft.com...[vbcol=seagreen]
> Amol,
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
> Thanks again.
> Steve
> "Amol Kher" wrote:
Invalid cast when trying to use SQLXMLBulkload
Example file: XSD file
<?xml version="1.0" standalone="yes"?>
<xschema id="STG_Additional_Labs" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn
chemas-microsoft-com:xml-msdata">
<xs:element name="STG_Additional_Labs" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xsequence>
<xs:element name="FacilityID" type="xs:int" minOccurs="0" />
<xs:element name="Comment" type="xstring" minOccurs="0" />
<xs:element name="Deleted" type="xs:boolean" minOccurs="0" />
<xs:element name="Lab_Date" type="xsateTime" sql
atatype="dateTime" minOccurs="0" />
<xs:element name="Lab_Name" type="xstring" minOccurs="0" />
<xs:element name="Lab_Time" type="xstring" minOccurs="0" />
<xs:element name="Lab_Value" type="xstring" minOccurs="0" />
<xs:element name="PIID" type="xs:int" minOccurs="0" />
<xs:element name="rowguid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="RowIDGuid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="SaveDateTime" type="xsateTime" sql
atatype="dateTime" minOccurs="0" />
<xs:element name="VersionGuid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="PatientID" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
</xsequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xschema>
Example file: XML file
<?xml version="1.0" standalone="yes"?>
<STG_Additional_Labs>
<Table>
<FacilityID>648</FacilityID>
<Deleted>false</Deleted>
<Lab_Date>2007-05-30T00:00:00-04:00</Lab_Date>
<Lab_Name>Stool Red Subst</Lab_Name>
<Lab_Value>trace</Lab_Value>
<PIID>14</PIID>
<rowguid>03cc9264-8829-464f-b01d-2b18ee4ccdfb</rowguid>
<RowIDGuid>ff9e4e59-6716-46d4-bfcb-61777ed8cf5d</RowIDGuid>
<SaveDateTime>2007-05-30T10:18:24.52-04:00</SaveDateTime>
<VersionGuid>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</VersionGuid>
<PatientID>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</PatientID>
</Table>
<Table>
<FacilityID>648</FacilityID>
<Deleted>false</Deleted>
<Lab_Date>2007-05-19T00:00:00-04:00</Lab_Date>
<Lab_Name>Stool Red Sub</Lab_Name>
<Lab_Value><0.25/ neg</Lab_Value>
<PIID>14</PIID>
<rowguid>876ca5f9-5c0f-4a74-bf03-2e86260ca2a1</rowguid>
<RowIDGuid>45c45895-8008-40ed-a779-c478d476c15b</RowIDGuid>
<SaveDateTime>2007-05-19T10:13:53.857-04:00</SaveDateTime>
<VersionGuid>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</VersionGuid>
<PatientID>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</PatientID>
</Table>
</STG_Additional_Labs>Ack! Sorry about the emoticons!|||Actually, further work on this problem seemed to reveal that the Cast error was actually due to the connection string in my application being wrong (although it is used for all the other connections in the application). The error now coming back is this:
<?xml version="1.0"?><Result State="FAILED"><Error><HResult>0x80004005</HResult><Description>
<![CDATA[Reference to undeclared namespace prefix: 'sql'.
]]></Description><Source>Schema mapping</Source><Type>FATAL</Type></Error></Result>
What would be the proper way to specify the SQL namespace in the top of the file?|||I have essentially resolved my problem by not trying to output the XML data to then read it in later. I am now using the SQLBulkLoad classes to pump the data from a DataTable to the destination SQL server. It would be nice however to have a method in the SQLReader/Writer that can write out a SQL friendly XSD file, so that it can be used later by the SQLXMLBulkLoad class.