简体   繁体   English

我们如何使用xml将空值发送到数据库?

[英]how do we send null values to a db using xml?

I'm trying to pass null values to a db through xml. 我正在尝试通过xml将空值传递给数据库。

            <parameter>
                <key>email</key>
                <value>tester@memoir-systems.com</value>
            </parameter>
            <parameter>
                <key>password</key>
                <value></value>
            </parameter>
            <parameter>
                <key>Customer</key>
                <value/>
            </parameter>
            <parameter>
                <key>Address</key>
                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:nil="true"/>
            </parameter>

I've tried all this but it is taking it as a empty string with length zero and not as a null . 我已经尝试了所有这些方法,但是将其作为长度为零的空字符串而不是null。

my xsd is

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="document">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="testCaseData" maxOccurs="unbounded" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:long" name="id" minOccurs="0"/>     
              <xs:element type="xs:string" name="testCaseName"/>
              <xs:element type="xs:string" name="expectedResult"/>
              <xs:element name="parameter" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element type="xs:string" name="key"/>
                    <xs:element name="value"  maxOccurs="unbounded" minOccurs="0" nillable="true"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Can anyone please help me fix this? 谁能帮我解决这个问题?

您必须在服务器端检查该值是否为空,然后在数据库中插入null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将差异值发送到db中的两个表中? - How do I send diffrent values into two tables in db? 我们如何使用Jersey发送请求中未注释的方法参数? - How do we send unannotated method parameter in request using Jersey? 如何在java中解析XML以使用STAX在db中保存值? - How to parse XML in java to save values in db using STAX? 我如何使用 java 在 protobuf 3 中发送 null 值? - How i can send null values in protobuf 3 using java? 如何替换XML中的空值 - How to replace null values in XML 如何发送空变量而不是空白变量到我的sql数据库? - How do I send a null variable, instead of a blank one to my sql DB? 如果csv文件具有空值并且我们需要与上一列相对应的数据,如何使用逗号分隔csv文件? - how to seperate a csv file using commas if it has null values and we need data corresponding to upper column? Java Streams 如何在映射新列表时检查空值并发送消息 - Java Streams how do i check for null values and send message while mapping for a new list 当表使用联接包含空值时,如何将数据从数据库添加到Java Swing中的jTable? - How to add data from a DB to jTable in Java Swing when tables contain null values using joins? 我们如何使用KLOV(范围报告)向MongoDB AWS发送信息? - How do we send information using KLOV(Extent Reports) to MongoDB AWS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM