Coder Social home page Coder Social logo

Support for XML 1.1 about ez-vcard HOT 4 CLOSED

 avatar commented on July 23, 2024
Support for XML 1.1

from ez-vcard.

Comments (4)

mangstadt avatar mangstadt commented on July 23, 2024

Sorry for the late response. Thank you for the suggestion. I'll look into it!

from ez-vcard.

mangstadt avatar mangstadt commented on July 23, 2024

I'm not sure how invalid characters are sneaking in there. ez-vcard uses Java's XML API to create the XML document, so it should automatically escape any characters that are not supported by XML 1.0. Can you include a code sample?

As for supporting XML 1.1, the code sample below might work for you. Although, apparently, this only works with certain JVMs (according to my testing)

XCardDocument xcardDoc = ...
Document doc = xcardDoc.getDocument();

Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.VERSION, "1.1");

DOMSource source = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
transformer.transform(source, result);

String xml = writer.toString();

from ez-vcard.

mangstadt avatar mangstadt commented on July 23, 2024

I posted a question on Stackoverflow about writing XML 1.1 document in Java. Apparently, the XML libraries bundled with the JDK are quite old, so you have to include a more up-to-date library to support 1.1.

If you add the xalan-2.7.2 library to your classpath, then you can use the code that I wrote in the above post to output an XML 1.1 document.

See: http://stackoverflow.com/a/31990430/13379

from ez-vcard.

mangstadt avatar mangstadt commented on July 23, 2024

Added the ability to specify the XML version when writing xCards: 10e22e7

from ez-vcard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.