Comments (5)
Btw, is this really correct?
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 (<> => <&>)
seems to be correct, though.
from xmltools.
I tried with v. 3.0.4.3 and it works for me with &, 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.
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.
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 (<> → <>)
escapes everything including quotes in all positions.
[1] https://wiki.python.org/moin/EscapingXml
from xmltools.
For information, the xmltools options dialog let you choose which character must be handled by text/xml conversion functions:
from xmltools.
Related Issues (20)
- XMLTools on ARM Windows 11 HOT 1
- When double-clicking an XPath match from the dialog (Evaluate XPath expression), it should point to the line and column in the file
- Performance improvements when pretty formatting large (10+ MB) XML files (if possible)
- Navigate to a node's parents (like in IntelliJ/PyCharm with "XPathView + XSLT" plugin) and keep current node in path
- Add support for libxml2 HOT 1
- Very unresponsive HOT 1
- Character class subtraction not recognized in schema regex. HOT 1
- Copy XPATH from STATUS BAR with Name;ID
- Request: add support for ends-with
- DTD is prohibited
- Request/Question: xml-tool "pretty print - indent attributes" via commandline or in batch HOT 1
- Validation of XML against Schema fails with no DTD/Schema declaration was found
- Pretty print not adding proper tabs HOT 2
- how to make the "mark done" disappear depending on a condition in Odoo14
- Evaluate XPath expression, XPath copying through `Current XML path` gives no result and dialog gives no hint HOT 2
- Can't click or copy an URL displayed in Plugins -> XML Tools -> Options...
- Unable to PrettyPrint an Xml File with the given shortcut
- NPP XML plug-in locks most recently used folder HOT 3
- "Pretty print ALT+SHIFT+B" command drops BOM on UTF-8 BOM files
- Annotation error mode does not respect word wrap enabled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmltools.