Comments (1)
After some thought - I think normalization will be actually more useful for being sure that declarations of used namespaces in fact exist in XML document. Also, as normalization may be a costly operation so it may a good idea to do it when parsing.
Idea sketch:
Add def parseNormalized: Either[FailType, (XmlDocument, Set[Namespace])
. Besides of returning set of defined namespaces (which is reflected on return type) it would also move all namespace declarations to root element. Then, if user is not interested in adding new namespace and just working on already defined he can use Set[Namespace]
returned by mentioned method for e.g. creating new elements.
We can have a symmetrical print method e.g. def printNormalized(doc: XmlDocument, namespaces: Set[Namespace])
which would print all namespaces
in root element.
The problem with that idea is that it still relies on assumption that user uses just namespaces returned by parseNormalized
. The API itself would not restrict him to e.g. add some element with completely different (and potentially not declared) namespace.
Another idea would be to use path dependant types to restrict user to use just declared namespaces. The disadvantage may be that AST itself would probably need to carry that info on typelevel. Reasonable solution would be to allow for arbitrary namespaces usages on AST and optics level and do the whole normalization thing (more precisely - restricting usages of namespaces just to declared ones) on DSL level.
from xml-lens.
Related Issues (16)
- XmlParser should read XML version and encoding
- Scala.js io module HOT 1
- Interoperability with XML literals
- Performance tests mimicking real usage
- Add more options to PrinterConfig HOT 1
- Decide on using monocle-cats
- Ensure that no internal types are leaking into client
- Equivalent to `javax.xml.stream.isCoalescing` in `XmlParser`
- How would I focus on only the instances of an element which have a particular attribute value? HOT 2
- FYI xmlformat... xml ADT and encoder / decoder HOT 2
- `Element`s don't compare equal when attributes are in different order
- PrettyPrinter
- Reasonable equal implementation for Node
- Make AST complete
- Benchmarks HOT 1
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 xml-lens.