I am using Oracle Service Bus 12C to translate REST calls between my and third-party servers.
I set the REST component on the proxy as well as the business side to use WSDL. I create 4 XSD's (for the proxy request, proxy response, business request and business response). In the pipeline, I use an XQuery transformation file to convert outgoing requests and incoming responses.
A typical transformation would be:
xquery version "1.0" encoding "utf-8";
(:: OracleAnnotationVersion "1.0" ::)
declare namespace ns1="http://TargetNamespace.com/NumberplateProxy_GetPendingRequests_response";
(:: import schema at "GetPendingRequestsProxyResponse.xsd" ::)
declare namespace inp1="http://TargetNamespace.com/NumberplateBusiness_GetPendingRequests_response";
(:: import schema at "../Business/GetPendingRequestsBusinessResponse.xsd" ::)
declare variable $statusCode as xs:string external;
declare variable $statusDescription as xs:string external;
declare variable $data external;
declare function local:func($statusCode as xs:string, $statusDescription as xs:string, $data) as element()
(:: schema-element(ns1:GetPendingRequests-ProxyResponse-Root-Element) ::)
(:: schema-element(inp1:GetPendingRequests-BusinessResponse-Root-Element) ::){
<ns1:GetPendingRequests-ProxyResponse-Root-Element
xmlns:ns1="http://TargetNamespace.com/NumberplateProxy_GetPendingRequests_response">
<ns1:statusCode>{fn:data($statusCode)}</ns1:statusCode>
<ns1:statusDescription>{fn:data($statusDescription)}</ns1:statusDescription>
{
if( $data eq "" ) then (
<ns1:data/>
) else (
for $x in $data/inp1:data
return <ns1:data>
<ns1:REQUESTID>{fn:data($x/inp1:REQUESTID)}</ns1:REQUESTID>
<ns1:REGISTRATIONNUMBER>{fn:data($x/inp1:REGISTRATIONNUMBER)}</ns1:REGISTRATIONNUMBER>
<ns1:CATEGORY>{fn:data($x/inp1:CATEGORY)}</ns1:CATEGORY>
</ns1:data>
)
}
</ns1:GetPendingRequests-ProxyResponse-Root-Element>
};
local:func($statusCode, $statusDescription, $data)
The pipeline debugger is used to view the workflow and the data. This works well except for when it comes to debugging what happens inside the XQuery. Is there any way to debug that?
I was wondering how to use a simple function using Symfony + Webpack + Encore.
I have my file accentsDelete.js with :
export default function accentsDelete(string) {
...
}
And in my app.js file :
import accentsDeletefrom './accentsDelete';
But I still get the error when I try to use accentsDelete('éléphant') in my Twig templates :
Uncaught ReferenceError: accentsDeleteis not defined
My Webpack config is almost the original one, do I need to specify a scope or something ?
So my query was working fine and I now need to verify the resulting .xml with a .dtd validation. My .xq looked like this before:
< root>
...
...
< /root>
Now it looks like this:
< !DOCTYPE root SYSTEM 'validation.dtd'>
< root>
...
...
< /root>
Running the .xq now, however, throws the following error:
XPST0003 XQuery syntax error near #...as xs:integer external; < !D#:
Expected '--' or '[CDATA[' after '< !'
Static error(s) in query
I don't know what this error means, and I'm unable to find how to fix it
Thanks in advance
To serialize an XML document with a document type declaration, use the fn:serialize() function with the doctype-system parameter:
xquery version "3.1";
fn:serialize(<root/>, map { "doctype-system": "validation.dtd" })
This produces the following string:
<!DOCTYPE root SYSTEM "validation.dtd">
<root/>
For more on this technique, see the function documentation for fn:serialize() at https://www.w3.org/TR/xpath-functions-31/#func-serialize and description of the doctype-system and doctype-public parameters in the XSLT and XQuery Serialization 3.1 Specification at https://www.w3.org/TR/xslt-xquery-serialization-31/#XML_DOCTYPE.
For processors that only support XPath 3.0 or that have not yet implemented the map(*) method of specifying serialization parameters, you can use this form:
xquery version "3.0";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
fn:serialize(
<root/>,
<output:serialization-parameters>
<output:doctype-system value="validation.dtd"/>
</output:serialization-parameters>
)
Folks, I'm trying to do something that I thought ought to be simple, but I must be doing something wrong. I'm trying to simply have a clear structure in my meteor application which uses Typescript.
Here are my requirements:
All interfaces are available in both client and server
Some class implementations are only available on the server
I don't want to rely on file load order for my application to work properly
I need my own module to not clash with global objects (such as the Position class for example)
I need to have one monolithic include file for server, one for both client and server and one for client (don't want to have 10s of includes on top of my files)
The setup that I have right now is this
server
server-book.ts
client
shared
collections.ts
definitions
server
include.d.ts (includes all .d.ts files in this folder)
server-book.d.ts (server specific implementation of book)
client
shared
include.d.ts (includes all .d.ts files here)
book.d.ts (book interface definition)
collections.d.ts
In each .d.ts file I have
module MyModule {
interface Bla {}
};
In each .ts file that defines a class I have:
module MyModule {
export class MyBla implements Bla {};
}
All .d.ts files generated for classes are generated by tsc -d.
No .ts files are being included via ///<reference> rather only .d.ts files.
Now, when I run this, I get an error that MyModule is undefined:
/// <reference path="shared/include.d.ts"/>
/// <reference path="server/include.d.ts"/>
Meteor.startup(() => {
var temp = new MyModule.ServerBook();
});
The error occurs right on MyModule.
What am I doing wrong? What should be the proper setup here?
Thanks!
I have dealt with this issue on my blog. I decided to use the evil eval command, since it gave me the easiest possibility of using modules till something more sophisticated appears.
File /lib/foo.ts is position in the subdirectory since it has to be loaded before Bar.
eval('var Hugo = (this.Hugo || (this.Hugo = {})'); // this will override the automatically emitted var Hugo and assigns it with globally defined Hugo module
module Hugo {
export class Foo {
foo():string {
return 'foo'
}
}
}
File /bar.ts
/// <reference path="lib/foo.ts"/>
eval('var Hugo = (this.Hugo || (this.Hugo = {})'); // this will override the automatically emitted var Hugo and assigns it with globally defined Hugo module
module Hugo {
export class Bar extends Foo {
bar () : string {
return 'bar';
}
}
}
File /test.ts
/// <reference path="lib/foo.ts"/>
/// <reference path="bar.ts"/>
var m = new Hugo.Bar();
console.log(m.bar());
console.log(m.foo());
As mentioned here, for classes, the solution is even simpler:
class ExportedClass {
variable : int;
}
this.ExportedClass = ExportedClass;
Definition files should use the declare keyword. You would normally get an error if you didn't use this keyword.
declare module MyModule {
export interface Bla {}
}
And
declare module MyModule {
export class MyBla implements Bla {
}
}
It is also worth checking that the ServerBook class has the export keyword (just like MyBla in your examples).
After lot of trial and errors, here are my findings so far :
Using typescript "module" keyword doesn't get well with Meteor. I think at the moment you cannot use it (or the workarounds are too complicated for me).
However, here is what you can do :
Let say that you have package A where you want to define a class ClassToExport which you want to make public.
class ClassToExport {
getFoo(){
return "foo";
}
}
Please note that you can't write this.ClassToExport = ClassToExport and
api.export('ClassToExport') or else ClassToExport won't be available in the global scope of package A, hence the need for a module/namespace for exporting your class, which we will see next.
Now, for the class to be available for the consumers of your package, you have to create a namespace, which will be the equivalent of the "module" typescript keyword for internal module.
So let's write :
declare var packageA; //so that the compiler doesn't complain about undeclared var
packageA = packageA || {}; //so that this namespace can be reused for the entire package
packageA.ClassToExport = ClassToExport; //the actual export
Now, don't forget to write
api.export('packageA') in the package.js of package A
If you have a package B where you want to use ClassToExport, you write in package B:
var cte = new packageA.ClassToExport();
without forgetting to api.use package A in package B's package.js
If you don't want to write the namespace each time you use the class, you can also write var ClassToExport = packageA.ClassToExport; at the top of your using file.
If you need a global class for you package only, without exporting it, then you can do instead just :
this.ClassToExport = ClassToExport
and again don't write api.export('ClassToExport'), or it won't be available in the package anymore.
This way, i think the features (export/ import) of internal typescript modules are there.
If you are not afraid of gulp build, I have prepared a typescript boilerplate project which allows you to comfortably use typescript from within your app, not depending on packages.
https://github.com/tomitrescak/meteor-boilerplate-typescript
Random idea, what about extend Meteor instead of Window.
Meteor.yournamespace = Meteor.yournamespace || {};
Meteor.yournamespace.myclass = new MyClass();
or
Meteor.yournamespace.MyClass = MyClass();
I think this is less invasive than go directly to the window object IMHO. my two cents.
now you can do Meteor.yournamespace.MyClass :P
--EDIT
Then you could create a meteor-extend.d.ts file and do something like:
/// <reference path="main.d.ts" />
declare module Meteor {
var yournamespace: any;
}
Now you can remove the <any> before Meteor and Typescript will not complaint.
I'm implementing an interface and now I'd like to get all implementations of this interface in classpath. Is this possible or should I do something else?
You can use the Reflections library for this sort of thing, ie; to find all classes in org.codehaus.groovy which implement the Iterator interface, you can do:
#Grab( 'org.slf4j:slf4j-api:1.7.5' )
#Grab( 'org.reflections:reflections:0.9.9-RC1' )
import org.reflections.*
new Reflections( 'org.codehaus.groovy' ).getSubTypesOf( Iterator ).each {
println it.name
}
Which prints:
org.codehaus.groovy.runtime.StringGroovyMethods$1
org.codehaus.groovy.runtime.SwingGroovyMethods$7
org.codehaus.groovy.util.ArrayIterator
org.codehaus.groovy.runtime.metaclass.ConcurrentReaderHashMap$KeyIterator
org.codehaus.groovy.control.CompilationUnit$9
org.codehaus.groovy.runtime.SqlGroovyMethods$ResultSetMetaDataIterator
org.codehaus.groovy.runtime.SwingGroovyMethods$1
org.codehaus.groovy.util.ManagedLinkedList$Iter
org.codehaus.groovy.runtime.SwingGroovyMethods$3
org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$2
org.codehaus.groovy.runtime.SwingGroovyMethods$6
org.codehaus.groovy.ant.FileIterator
org.codehaus.groovy.runtime.IOGroovyMethods$3
org.codehaus.groovy.runtime.DefaultGroovyMethods$DropWhileIterator
org.codehaus.groovy.runtime.DefaultGroovyMethods$TakeIterator
org.codehaus.groovy.runtime.DefaultGroovyMethods$3
org.codehaus.groovy.runtime.SwingGroovyMethods$5
org.codehaus.groovy.runtime.SwingGroovyMethods$2
org.codehaus.groovy.runtime.metaclass.ConcurrentReaderHashMap$HashIterator
org.codehaus.groovy.runtime.metaclass.ConcurrentReaderHashMap$ValueIterator
org.codehaus.groovy.runtime.XmlGroovyMethods$1
org.codehaus.groovy.runtime.SwingGroovyMethods$4
org.codehaus.groovy.runtime.IOGroovyMethods$2
org.codehaus.groovy.runtime.ReverseListIterator
org.codehaus.groovy.runtime.DefaultGroovyMethods$TakeWhileIterator