8 Replies Latest reply: Jun 30, 2011 1:42 AM by 802245 RSS

    Problem in saving the ½, ¼, ¾ values in database using xml

    853982
      Hi

      I am developing a java swing based application. In which I send data in xml format and save it on a online webstore through API calls.

      When I send the data in following format 3½, 3¼, 3¾. It saves only 3 not the whole value means It is ignoring the values ½, ¼, ¾.

      Here is my xml code which I am sending on network.
      <?xml version="1.0" encoding="UTF-16" standalone="yes"?>
      <product>   
          <product-type>Shirts</product-type>
          <title>testStyle</title>
          <variants type="array">
              <variant>
                  <fullfilment-service>manual</fullfilment-service>
                  <inventory-management>shopify</inventory-management>
                  <inventory-policy>deny</inventory-policy>
                  <option1>Black</option1>
                  <option2>3¼</option2>
                  <option3 nil="true"></option3>
                  <price>40.0</price>
                  <requires-shipping>true</requires-shipping>
                  <sku>1307681713338</sku>
                  <taxable>true</taxable>
              </variant>
              <variant>
                  <fullfilment-service>manual</fullfilment-service>
                  <inventory-management>shopify</inventory-management>
                  <inventory-policy>deny</inventory-policy>
                  <option1>Black</option1>
                  <option2>3½</option2>
                  <option3 nil="true"></option3>
                  <price>40.0</price>
                  <requires-shipping>true</requires-shipping>
                  <sku>1307681714634</sku>
                  <taxable>true</taxable>
              </variant>       
          </variants>   
      </product>
      In option2 tag I am passing ½, ¼, ¾.

      Please give me some solutions .

      Thanks

      Edited by: Sonal on 28-Jun-2011 22:28
        • 1. Re: Problem in saving the ½, ¼, ¾ values in database using xml
          EJP
          What does the code that receives the XML look like?
          • 2. Re: Problem in saving the ½, ¼, ¾ values in database using xml
            802245
            Sonal wrote:
            When I send the data in following format 3½, 3¼, 3¾. It saves only 3 not the whole value means It is ignoring the values ½, ¼, ¾.
            Please verify these:_
            *1.* Check the Database you are using supports and using 'UTF-16 Character Set' to store data. Check database settings.
            *2.* Check the parser you are using supports and using 'UTF-16 Character Set' to parse XML. Check Parser Properties.

            It seems the problem is because of character set which do not support characters like ½, ¼, ¾.
            • 3. Re: Problem in saving the ½, ¼, ¾ values in database using xml
              853982
              hi

              Thanks for your reply.

              I am using JAXB Parser for parsing. Here is my code.
                        // Prepare for XML marshalling
                        JAXBContext jaxbContext = JAXBContext.newInstance(ProductVariant.class);
                        Marshaller marshaller = jaxbContext.createMarshaller();
                        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                        StringWriter stringWriter = new StringWriter();
                      // Marshall product variant to XML
                        marshaller.marshal(objProductVariant, stringWriter);
                      // Prepare request content
                        String entityString = stringWriter.toString();              
                              StringEntity entity = new StringEntity(entityString);
                        entity.setContentType("application/xml");
                        httpPost.setEntity(entity);                      
                      // Execute API call
                        HttpResponse response = httpClient.execute(httpPost);
              ProductVariant is a class name and objProductVariant is a name of object.
              When I check the entityString value, 3½ is present there but after saving it, when I check in database it store 3 only.
              • 4. Re: Problem in saving the ½, ¼, ¾ values in database using xml
                802245
                Sonal wrote:
                When I check the entityString value, 3½ is present there but after saving it, when I check in database it store 3 only.
                Check Database settings as I had suggested in my previous post...
                • 5. Re: Problem in saving the ½, ¼, ¾ values in database using xml
                  EJP
                  What does the code that receives the XML look like?
                  Here is my code.
                  What does the code that receives the XML look like?
                  • 6. Re: Problem in saving the ½, ¼, ¾ values in database using xml
                    853982
                    Actually It is a online webstore.
                    If I directly go to the website and create a product variant and save it.
                    It saves it successfully means 3½ value successfully saved into database.
                    but when I try it through my code, It is not saving it.

                    Any help would be appreciated.
                    Thanks
                    • 7. Re: Problem in saving the ½, ¼, ¾ values in database using xml
                      EJP
                      So it isn't your code?

                      So you need to sniff the network to see what the browser is sending, and adjust your code to do the same.

                      Seems like a character-set problem at first guess.
                      • 8. Re: Problem in saving the ½, ¼, ¾ values in database using xml
                        802245
                        EJP wrote:
                        Seems like a character-set problem at first guess.
                        This is what I had indicated in my first post.
                        Tejas wrote:
                        It seems the problem is because of character set which do not support characters like ½, ¼, ¾.
                        Sonal, Do check in your code that what ever classes you are using supports and using appropriate Character Set.