Which tools exist for static analysis of XQuery functions?
Example tasks: given two XSD schemas A and B and some XQuery f, check that for any document d of type A its transformation f(d) is valid against B.
Or for given query generate its inverse, when exists.
This topic is unfortunately hard for googling.
Yes, I think OxygenXML is fantastic for XQuery analysis, it has its own manual static-analysis tools built in.
You can use the manual validation instead: Document > Validate > Validate after configuring a transformation or a validation scenario that specified the xDB connection as the engine.
Other resources I found which where interesting on this topic Using XML Editor to Create or Validate an OLAC Static Repository and Where can I find static/dynamic code analysis tools for XSLT? (Oxygen can be used with X-Query, X-Path, XLink to name a few).
Related
The first question I get from most of the developers I get is, Is there any way to auto generate your groovy file by by using swagger or may be plain json file?
Is there any way to do it?
I don't understand the question. What do you want to achieve? Do you NOT want to use Groovy file to define a contract? If that's the case then the answer is - you can use the Pact file (a json) to define the contract or you can plugin whatever you want. It's all written in the documentation - http://cloud.spring.io/spring-cloud-static/Dalston.SR4/multi/multi__pluggable_architecture.html.
As for Swagger we don't support it mainly because it's a schema. The reasons behind this decision are in this issue - https://github.com/spring-cloud/spring-cloud-contract/issues/136
In order to create a simple annotation that logs function calls, I'm trying to grab the following attributes from a function that has said annotation:
Function name
Parameter names
Parameter values
What I have so far uses KCallable as a value, which makes grabbing the name and names from the list of KParameter fairly simple. However, I cannot figure out how to get the values of said parameters to make the log statement more contextual.
Does anyone have ideas on grabbing these parameters values within the annotation? It doesn't need to use KCallable, that just seemed like the most intuitive receiver.
You will need a different approach. Annotations and parameter type are a compile time features while values are a runtime feature.
What you will have to do is use a bytecode processing framework like ASM or google "aspect oriented programming". That allows you to examine the generated bytecode and modify if before the JVM tries to execute it.
The other approach is to write a Kotlin compiler plugin which generates the necessary code (google "Writing Your First Kotlin Compiler Plugin")
This blog post contains an example for Java and Spring using the AOP approach: https://solocoding.dev/blog/eng_spring_centrlize_logging_with_aop
I recommend the compiler plugin because the other approach is much more complicated, brittle and badly documented. Use AOP only if you find a framework which already contains all the features you need.
I am new to ANTLR and trying to see if ANTLR fit into my scenario or I should stick to JSON deserialization library and write some custom code.
Input text is a JSON which represents an expression like
{
"Operator":"ADD",
"Operands": [{"Operator":"ADD", "Operands":[{"OperandValue":23},{"OperandValue":32} ]},
{"Operator":"ADD", "Operands":[{"OperandValue":11},{"OperandValue":12} ]}]}
}
list of Operators can evolve
JSON is created programmatically and not manually created by users by hand.
I have to read this JSON and validate it and give meaningful error messages to my client.
If JSON in valid/parsed, I have to translate JSON to TSQL code and execute on SQL server.
All my code will be in C# and I need:
max Debug support and ease
unit testability
less custom code
min. learning
With above two needs, I tried to write a rough ANTLR grammar and custom code and below are my observation
ANTLR in a way my logic will reside grammar file, which might be difficult to
debug writing grammar for new comer. and unit test. for doing my grammar POC I was relying only context.GetText() property to figure out where I am currently and change my grammar.
I have to write a modularized grammar(building blocks), so that I can have visitor for my smallest part and more manageable visitor class.
How can I give more meaning full messages to my clients, with them having least knowledge of my grammar parsing engine?
custom JSON deserialization (JSON.NET)
code easy to debug, and everyone understands. I get a JSON reader and write condition to check if JSON Object or JsonArray and if it has Property Operator with value ADD and similar.
custom code I can give more meaningful validation failure messages.
To me ANTLR seems to have high value when your input is not highly structured and you don't have available parsers, but in case of JSON it doesn't give much value add over JSON parsers.
Is ANTLR meant for this scenario?
I try to set up a web based application using spring and xslt. Since i always use xslt in a pipelining style, i would like to use calabash. Is there a possibility to call calabash from Java? I read thru the documentation on http://xmlcalabash.com but there is only a description how to use it from command line. I also tired to find some javadoc on githup but wasn't successful. Obviously, there is the Main class with the main() method and i could supply the command line parameters as a string array...
I wonder if there is a better way to do it.
I looked into this recently too. I took a pragmatic approach where I call Main.run(), and pass in a string array that I generate from a (File)Properties object. It doesn't allow passing in file inputs as streams or sources however, they must reside on the file-system.
Likely there are nicer ways. You could for instance look into http://expath.org/ . There should be sources of that project. The webapp modules (formerly known as servlex?) seems to provide XMLCalabash integration.
HTH!
I have seen questions here asking about xsd->actionscript objects, but these seem to require xsd->java->actionscript and is all in source code. Our requirements are a bit different:
receive an xsd during runtime that we have never seen before
Create an instance object based on the xsd
fill in the values of the instance (either from an xml document or user input - whatever)
Anyone know of an actionscript library or tool that would help us accomplish this at runtime? It would be nice if something like this already existed - but we would certainly settle for a library that gave us a programmatic interface to extract information from an xsd schema. Additionally, we would take suggestions on alternate methods to accomplish the same ends.
Have you looked at the SchemaLaoder...? Not EXACTLY what you're looking for ... But a great start.
First - you should check this blog entry and this blog entry which walks you through Dominic De Lorenzo experiences with utilising functionality within the Flex SDK that provides the automatic mapping of custom ActionScript classes to element definitions within an XML Schema (XSD).
The steps to get moving here include (from Dominic's blog):
0) Create an instance of SchemaLoader and asynchronously load an XML schema from a given URL
1) Once the schema is loaded, add it to the SchemaManager and register any ActionScript classes to their corresponding schema type
---- At this stage you can do several operation based on the schema
2) Load an XML file based off that schema
3) Once the XML is loaded, decode the contents using XMLDecoder. Any classes registered in the schemaTypeRegistry will be used when decoding the xml
4) Encode a custom ActionScript class back into XML using XMLEncoder. XMLEncoder.encode() supports various ways to define the corresponding element in the schema (top level element, a specific type or even a custom XSD definition) that will be used to encode the Actionscript object.
The blog entry has links to code samples, etc...
Hope this helps.