IntelliJ Idea: Schemas and DTDs / configuring XML catalog - intellij-idea

I have a lot of xml files in my project which are described with many xsd schema files.
XSD schemas use complex namespace structure and I want to configure IDE (IntelliJ Idea) to resolve URIs of these schemas on my local file system (https://www.jetbrains.com/idea/help/xml-catalog.html).
So I open Idea Settings, select Language & Frameworks -> Schemas and DTDs -> XML Catalog and point the path to xml-catalog.properties file with following content:
catalogs=xml-catalog.xml
relative-catalogs=yes
#verbosity=99
Next I create xml-catalog.xml file (in the same directory as the xml-catalog.properties file):
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:tc:entity:xmlns:xml:catalog http://www.oasis-open.org/committees/entity/release/1.0/catalog.xsd"
prefer="public">
<rewriteSystem systemIdStartString="http://www.mycompany.com/schemas" rewritePrefix="file:///c:/Projects/MyProject/schemas"/>
</catalog>
I expect Idea will resolve all the schemas with prefix http://www.mycompany.com/schemas in my local directory c:/Projects/MyProject/schemas and uses them for validating and code highlighting. But all the URIs in the editor remain red...
Googling and playing with paths, URIs and directives in xml-catalog.xml gave no results for me...
Could anyone show me working XML catalog settings which help to resolve at least one URI or public/system or point me detailed manual of doing this?..

Per the OASIS XML Catalog specification [1] your example should work as follows:
http://www.mycompany.com/schemas/foo.xsd
rewrites to:
file:///c:/Projects/MyProject/schemas/foo.xsd
Have you tried using a 'rewriteURI' [2] instead of a 'rewriteSystem' [1] ?
Here is an example that we've been using extensively for several years at JPL. At least, I know this works reliably on linux & macosx; however, I don't make any claims about windows.
<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
<rewriteURI
rewritePrefix="file:./www.omg.org/"
uriStartString="http://www.omg.org/"/>
</catalog>
With the Apache XML Resolver 1.2 library implementation [3], the above rewrites the following URI:
http://www.omg.org/spec/UML/20110701/UML.xmi
to:
file:./www.omg.org/spec/UML/20110701/UML.xmi
However, IntelliJ 14.1.3 says that the above is ill-formed; specifically, IntelliJ claims the attribute 'uriStartString' is not allowed and that 'rewriteURI' is missing the 'uriIdStartString' Attribute. That is, IntelliJ expects this:
<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
<rewriteURI
rewritePrefix="file:./www.omg.org/"
uriIdStartString="http://www.omg.org/"/>
</catalog>
The Apache XML Resolver 1.2 library does not handle this form.
Who to trust: IntelliJ? OASIS? Apache XML Resolver?
It does not help that the OASIS XML Catalog spec 1.0 uses 'uriStartString' in [2] and Appendix B (non-normative) but 'uriIdStartString' in Appendix A (non-normative).
It would be great if Norm Welch could comment on this; after all he wrote the OASIS XML Catalog spec and has been involved in the Apache XML Resolver implementation.
[1] https://www.oasis-open.org/committees/entity/spec-2001-08-06.html#s.rewritesystem
[2] https://xerces.apache.org/xml-commons/components/resolver/resolver-article.html
[3] https://www.oasis-open.org/committees/entity/spec-2001-08-06.html#element-rewriteURI

Related

Allow more than 2 gb file upload in struts2

I am using Struts 2.1 in my project.
In struts.xml maxsize element in my project is as follows :
<constant name="struts.multipart.maxSize" value="2147483648" />
For the file upload process,
is it possible to supersede the normal 2 Gb file limit of Struts2 ?
You should migrate to the latest version of Struts2.
From 2.3.20 and above, a new MulitpartRequest implementation can be used to upload large files:
Alternate Libraries
The struts.multipart.parser used by the fileUpload interceptor to
handle HTTP POST requests, encoded using the MIME-type
multipart/form-data, can be changed out. Currently there are two
choices, jakarta and pell. The jakarta parser is a standard part of
the Struts 2 framework needing only its required libraries added to a
project. The pell parser uses Jason Pell's multipart parser instead of
the Commons-FileUpload library. The pell parser is a Struts 2 plugin,
for more details see:
http://cwiki.apache.org/S2PLUGINS/pell-multipart-plugin.html. There
was a third alternative, cos, but it was removed due to licensing
incompatibilities.
As from Struts version 2.3.18 a new implementation of MultiPartRequest
was added - JakartaStreamMultiPartRequest. It can be used to handle
large files, see WW-3025 for more details, but you can simple set
<constant name="struts.multipart.parser" value="jakarta-stream" />
> in struts.xml to start using it.

Jruby: How to use third party java library?

I want to use java third party qr code libary https://github.com/kenglxn/QRGen library for generating qr code.
Please guide me as i don't know how to integrate java library in jruby.
The trick in this case is to find how to properly import the 3rd party libs.
Please download the needed jars using any dependency system (I use ant with ivy).
This will download 5 jars based on the qr code library you mentioned: core-2.0.jar core-3.1.0.jar javase-2.0.jar javase-3.1.0.jar jfreesvg-2.1.jar
build.xml for ant:
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="" default="retrieve">
<!--setproxy proxyhost="" proxyport="" proxyuser="" proxypassword=""/-->
<target name="retrieve">
<ivy:retrieve/>
</target>
</project>
ivy.xml for ivy:
<ivy-module version="2.0" >
<info organisation="" module=""/>
<dependencies defaultconf="default">
<dependency org="net.glxn.qrgen" name="javase" rev="2.0"/>
</dependencies>
</ivy-module>
Now typing ant retrieve will download and store 5 jars in lib subfolder.
If you do not have a dependency manager, here are the 5 jars urls you need to download manually and you need to move to a subfolder called lib:
http://search.maven.org/remotecontent?filepath=net/glxn/qrgen/javase/2.0/javase-2.0.jar
http://search.maven.org/remotecontent?filepath=com/google/zxing/javase/3.1.0/javase-3.1.0.jar
http://search.maven.org/remotecontent?filepath=com/google/zxing/core/3.1.0/core-3.1.0.jar
http://search.maven.org/remotecontent?filepath=net/glxn/qrgen/core/2.0/core-2.0.jar
http://search.maven.org/remotecontent?filepath=org/jfree/jfreesvg/2.1/jfreesvg-2.1.jar
I strongly advise you to use a java dependency manager if you wish one day to upgrade the revisions of the java libraries used in this code snippet.
Next step is to use the following ruby snip.rb code in the same folder. :
require 'java'
%w[
lib/core-2.0.jar
lib/core-3.1.0.jar
lib/javase-2.0.jar
lib/javase-3.1.0.jar
lib/jfreesvg-2.1.jar
].map &method(:require)
# this is the CRITICAL line to get it to work...
include_class 'net.glxn.qrgen.javase.QRCode'
# get QR file from text using defaults
# this will write a file (example: QRCode7247556396487679822.png) in java.io.tmpdir as defined in your JVM
file = QRCode.from("Hello World").file()
p file.name
# get QR stream from text using defaults
# if we redirect the stream as a byte array, we can have a better file control
include_class 'java.io.FileOutputStream'
stream = QRCode.from("Hello World").stream()
fos = FileOutputStream.new("QRCode.png")
fos.write(stream.toByteArray())
fos.close()
# fun with VCards
include_class 'net.glxn.qrgen.core.vcard.VCard'
johnDoe = VCard.new("John Doe")
johnDoe.setEmail("john.doe#example.org")
johnDoe.setAddress("John Doe Street 1, 5678 Doestown")
johnDoe.setTitle("Mister")
johnDoe.setCompany("John Doe Inc.")
johnDoe.setPhoneNumber("1234")
johnDoe.setWebsite("www.example.org")
stream = QRCode.from(johnDoe).stream()
fos = FileOutputStream.new("VCard.png")
fos.write(stream.toByteArray())
fos.close()
# all generated PNG can be decoded online using http://zxing.org/w/decode.jspx
Please note: jruby and java.io.tmpdir do not play well together in this particular jar case, as any call to QRcode creation with #file() will store file in java.io.tmpdir, whereever it is located. You've little control on the file location.
So I modified the original code answer to use the stream instead and create files with finer control.
You can verify all files generated with this useful URL: http://zxing.org/w/decode.jspx

Liquibase 3.2 not finding dbchangelog-3.2.xsd

Running version 3.2 I am getting an error
[WARN] liquibase - schema_reference.4: Failed to read schema document 'http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
When I look for http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd it is not there, although http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd is.
I came accross this https://liquibase.jira.com/browse/CORE-1840, which I interpret to say you dont need access to the internet to get dbchangelog-3.2.xsd. It doesnt seem to help when the internet is available but the .xsd is not there.
I have reverted back to 3.1 but would like to know the root cause of my 3.2 problem.
Updating the liquibase version to the latest solved my problem
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.3</version>
</dependency>
I solved it by distributing the schema with my application and referring to it locally (relative path). In the example below I have the schema file in the same folder as the changelog.
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.1.xsd">
<!-- all the things -->
</databaseChangeLog>
Liquibase does not looking for xsd in Internet. http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd will be replaced to path to java recources
More detailed info can be find here
I fixed the issue following what found here.
The solution works only for the one using maven-liquibase-plugin.
You have to run liquibase migration with the following option -Dprefer.internal.xsd=true:
mvn -Dprefer.internal.xsd=true liquibase:update
Check your changlog.xml file headers having xsd document version.
If it doesn't match it will during spring boot:run

__adobe_cep__.showDevTools() doesn't work since 14.2 update

On Photoshop CC 14.0 this code:
__adobe_cep__.showDevTools();
was showing Chrome Debug console.
On Photoshop CC 14.2, it does not work - nothing happens, no errors reported, console does not show.
What might be the issue?
Even though this is a really old question, I want to answer it. I'm new to PS extension development and this question is still the second hit on google.
This debugging mechanism is deprecated now (see this adobe CC article). The "official" debugging is now remote debugging.
You need to enable it by setting the PlayerDebugMode in your photoshop preferences to string "1".
Then you place a textfile called .debug in your extensions root directory. In this file you put XML to specify your debugging TCP port:
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionList>
<Extension Id="com.example.photoshopextension">
<HostList>
<Host Name="PHXS" Port="8088"/>
</HostList>
</Extension>
</ExtensionList>
Then you can access the tools by opening http://localhost:8088.

Cannot find message resources under key org.apache.struts.action.MESSAGE in struts

I am getting the following error in the browser window :
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
I have included the resource file in the struts-config.xml using
And my resource file is stored as WEB-INF/classes/Application.properties file.
Well this is an old post, but my answer can help, I guess...
I personally wasted some time to make work a poject that had been developped under Tomcat 5.5 under Tomcat 7.
Note : You should name your ressource file : "ApplicationResources"...
There is several reasons why it wouldn't work, but the most common answer I found on the net was : put the line
<message-resources parameter="ApplicationResources" null="false" />
in your "struts-config.xml".
In my case, this line was already present, and this was the contrary : I had to remove it and replace at the "web.xml" file level by :
<context-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</context-param>
in the "servlet" tag.
I'm sorry that I don't have a valuable explanation for this, but my application behaves just fine now.
Does anyone has (an explanation) ?
This happened to me because I was converting my project to maven and my resources directory was not correct.
I had struts-config.xml like this:
<message-resources parameter="messages.appResources" null="false"/>
My pom.xml was like this:
<resource>
<directory>src/main/resources</directory>
</resource>
But my messages folder was in my project root. So I moved it to:
${project.basedir}/src/main/resources/messages
Make sur that you are using the same version of the DTD in the header of struts-config.xml:
I had this error when using two differents versions:
//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
and the Pb was solved once the correction made:
An XML might be missing...
In which context is your application running ? Tomcat ? JBoss ?
Try including xalan and xerces dependencies.
The following solved my problem:
In Struts Config, include:
(At the top)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<message-resources
parameter="common.properties.Common" /> (or the path to your resources file)
This error seems to be caused by a lack of a path to message-resource in struts-config.xml
and the DOCTYPE definition at the top of the same.
you should put this line in your struts-config.xml
< message-resources parameter="ApplicationResources" null="false" key="ApplicationResources" />
In my case problem was fixed after delete all unnecessary attributes from message-resources element in struts-config.xml file. Just like following:
<message-resources parameter="ApplicationResources"/>