XSD:如何编码字符串长度> 255?
我尝试使用以下代码从 XML 导入字符串
<xs:element minOccurs="0" name="FIELDNAME" type="xs:string" />
,但某些字段超过 255 个字符。所以我尝试添加更多字符:
<xs:element minOccurs="0" name="FIELDNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1024" />
</xs:restriction>
</xs:simpleType>
</xs:element>
验证失败的数据长度为 194 个字符,包括 CDATA。它不包括单引号(它们在那里显示空格):
<FIELDNAME><![CDATA[
'
900207 4.5" FOOTED BOWL <BR>
'
]]></FIELDNAME>
SQL Server SSIS 2008 中的错误是:
Error: 0xC02090FA at Import, XML Source [1]: The "component "XML Source" (1)"
failed because truncation occurred, and the truncation row disposition on
"output column "FIELDNAME" (149)" at "output "DATA" (10)" specifies failure
on truncation. A truncation error occurred on the specified object of the
specified component.
如何构建首先列出的 XML 架构来导入此数据而不会出现错误?
I tried the following code to import a string from XML
<xs:element minOccurs="0" name="FIELDNAME" type="xs:string" />
But some fields are more than 255 characters. So I tried adding more characters:
<xs:element minOccurs="0" name="FIELDNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1024" />
</xs:restriction>
</xs:simpleType>
</xs:element>
The data that fails validation is 194 characters long including the CDATA. It does not include the single quotes (they are there to show the white space):
<FIELDNAME><![CDATA[
'
900207 4.5" FOOTED BOWL <BR>
'
]]></FIELDNAME>
The error in SQL Server SSIS 2008 is:
Error: 0xC02090FA at Import, XML Source [1]: The "component "XML Source" (1)"
failed because truncation occurred, and the truncation row disposition on
"output column "FIELDNAME" (149)" at "output "DATA" (10)" specifies failure
on truncation. A truncation error occurred on the specified object of the
specified component.
How would I construct the XML schema first listed to import this data without error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯...好吧,如果它不了解数据库,请尝试这个。
如果右键单击 xml 源组件,是否有“显示高级编辑器”选项?
如果是这样,请转到输入和输出属性选项卡,您可以从那里更改列元数据。
Hmmm... Well if it doesnt know about the DB yet try this.
If you right-click on the xml source component, do you have the option "show advanced editor"?
If so, go to the input and output properties tab, from there you can change the column metadata.
如果截断不是问题(尽管我假设是),您可以设置该列的 XML 源的错误输出,以忽略错误或重定向行。
If truncation is not an issue (although I'm assuming it is), you can set the Error Output from your XML Source for that column to either ignore the error or Redirect the row.
您确定这不是对数据库中列本身的限制吗?
我刚刚在访问中遇到了这个问题,将字段类型从“文本”更改为“备忘录”。
也许您需要将其更改为 varchar(max)。 (注:Max是关键字,不是要插入的数字)
Are you sure that its not a restriction on the column itself in the database?
I just had this issue in access, changed field type from "Text" to "Memo".
Perhaps you need to change yours to varchar(max). (Note: Max is a keyword, NOT a number to be inserted)