Comments (5)
Hi,
Each existing xsd type has its own visitor already defined at the moment.
- If what you want is to "replace" a visitor for a xsd element that is already defined in this library you may have to register a diferent type for that tag. For example:
- The type
XsdUnion
is already defined, with a visitor of type ofXsdUnionVisitor
and registered in typeDefaultParserConfig
as the type responsible for parsing thexsd:union
tags, which is done by this line:
parseMappers.put(XsdUnion.XSD_TAG, XsdUnion::parse);
- You may implement your own version of a
XsdUnion
with a diferent implementation of theXsdAbstractElementVisitor
interface and register it instead of the current type.
- If you want to add a new type with the respective implementation of a Visitor to include logic for a new tag you just have to define an implementation of
XsdAbstractElement
andXsdAbstractElementVisitor
and register it in your ownParserConfig
as explained above.
Sorry for the long response, it was an interesting question that I didn't even considered while developing the library a long time ago.
Hope it helped!
from xsdparser.
Hi,
thank you for the response! This can work for me, but I thought more on something like this:
For each Xsd node type I can register a visitor without providing a new implementation for the respective Xsd node type. In the example above, I want to extend the XsdUnionVisitor class and give it as a visitor implementation to the XsdUnion instead of XsdUnionVisitor.
For example, JavaCC gives such a freedom and using Visitors one can apply, for instance, type checking oder code generation by traversing the abstract syntax tree (AST). The use of the XsdParser can be extended to be used, for example, in this way:
XsdParser xsdParser = new XsdParser(Config.XSD_SOURCE_PATH.concat(fileName));
xsdParser.registerVisitor(myVisitor);
List xsdSchemas = xsdParser.getResultXsdSchemas().collect(Collectors.toList());
myVisitor.getAllReplacedRefElements()
....
However, the proposed solution is helpful and I can work with it. But it will be nice if one can add functionality just via the API using the visitor pattern without changing the code in the library.
Best regards,
Ivo
from xsdparser.
Hello,
I've made some changes to the way that element classes are attached to visitors. Now each element receives a function to create their own XsdAbstractElementVisitor which can be configured by implementing the interface ParserConfig
. The parser currently provides a default implementation of the Config but you can make your own.
I'll deploy this new version later today.
Edit: The new version with these changes is available: 1.0.26.
from xsdparser.
Thank you very much!
I will look at it and will give you a feedback in the course of the day.
from xsdparser.
I can work with the extension.
Thank you!
from xsdparser.
Related Issues (20)
- Parent releationship strange (or broken?) HOT 3
- attribute is missing HOT 14
- Target namespaces HOT 6
- Transitive includes not supported HOT 2
- error with xsd: import using subdirectories in schemaLocation HOT 1
- No child elements in XsdRestriction HOT 3
- FileNotFoundException for nested XSD HOT 1
- XsdParserJar::parseJarFile fails for valid schema compared to XsdParser HOT 6
- XsdAnnotation not filled in for XsdEnumeration ? HOT 2
- Embedded simple types fails HOT 1
- Problems using XsdParser in Windows HOT 3
- Trying to parse us-gaap taxonomy xsd, parser throws "namespace for prefix 'xlink' has not been declared" HOT 1
- Some advice needed on xs:appInfo HOT 1
- Upgrade jacoco to version 0.8.4 as needed for OpenJDK 11 HOT 1
- testDocumentationWithCDATA fails HOT 1
- Unable to get access from maven for version 1.2.2 HOT 1
- XML Schema causes XsdParser to exit with NullPointerException when calling isRelativePath() HOT 6
- I can't get the base ComplexType of a Restriction inside a complexContent HOT 2
- Resolution of imports via XML Catalog HOT 1
- compatibility break in xsdRestriction version 1.2.4 HOT 3
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 xsdparser.