Giter Club home page Giter Club logo

Comments (5)

Sopor avatar Sopor commented on July 28, 2024

Btw, is this really correct?

image

When i want to convert text to XML i need to use Convert selection XML to text and not Convert selection text to XML. The (<> => &lt;&&gt;) seems to be correct, though.

from xmltools.

github-canni avatar github-canni commented on July 28, 2024

I tried with v. 3.0.4.3 and it works for me with &amp, though I would expect a slightly different behavior

Expected behaviour:

Function to de-/encode special chars within selected tags (which are not marked as CDATA):

chars are replaced with ' " & < > and vice versa

It also encodes tags though if selected, so I would expect it to encode only the content of a tag
(Use Case: Usually I would like to select whole parts of a file and then "encode" content of all non-cdata tags)

from xmltools.

LetMeSleepAlready avatar LetMeSleepAlready commented on July 28, 2024

The de/encode is a simple text replacement algo. It has no notion of XML itself other than that it has to replace certain texts.

Lets explore the use cases:

Use case 1:
I have text, which I need to insert into XML.. however it might have illegal/reserved characters that will mess up the XML format. Hence, I select the text that I inserted and run 'Convert selection XML to text'... now my text is valid XML text.

Use case 2: I have some text node in XML that is encoded. Without using a full XML parser, I select this text and then run 'Convert selection text to XML. Now my selection is regular text and I can copy/paste it somewhere.

Use case 3:
I copy/pasted some & encoded text which was part of a cookie/URL-query/etc and want to decode it to XML. I select all and run 'Convert selection text to XML'. I will now have an XML document that I can work with.

Neither of these use cases require CDATA knowledge. Can you maybe describe your use case in detail?

from xmltools.

mikekaganski avatar mikekaganski commented on July 28, 2024

As described in a Python article dedicated to XML escaping [1], there are two separate cases to consider when escaping: CDATA and attributes. In the former case, there's no need to handle quotes; in the latter, quotes should be treated.

It seems logical to have dedicated functions here for the two cases; or maybe be smart to check the context (but then it would be not very flexible for cases where context in not clear, as in a temporary file without proper XML structure used for intermediate work). Currently (in version 3.0.4.3) the function Escape characters in selection (<> → &lt;&gt;) escapes everything including quotes in all positions.

[1] https://wiki.python.org/moin/EscapingXml

from xmltools.

morbac avatar morbac commented on July 28, 2024

For information, the xmltools options dialog let you choose which character must be handled by text/xml conversion functions:

2020-11-05_08h16_03

from xmltools.

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.