我有一个类从第三方源解组xml(我无法控制内容).这是解组的片段:
JAXBContext jContext = JAXBContext.newInstance("com.optimumlightpath.it.aspenoss.xsd");
Unmarshaller unmarshaller = jContext.createUnmarshaller() ;
StringReader xmlStr = new StringReader(str.value);
Connections conns = (Connections) unmarshaller.unmarshal(xmlStr);
Run Code Online (Sandbox Code Playgroud)
Connections是使用xjc生成的dtd-> xsd->类的类.该包com.optimumlightpath.it.aspenoss.xsd包含所有这些类.
我收到的xml包含DOCTYPE中的相对路径.基本上str.value上面包含:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE Connections SYSTEM "./dtd/Connections.dtd">
<Connections>
...
</Connections>
Run Code Online (Sandbox Code Playgroud)
这作为java 1.5应用程序成功运行.为了避免上面的错误,我不得不在项目根目录下创建一个./dtd目录并包含所有dtd文件(不知道为什么我必须这样做但我们会这样做).
我已经在Tomcat5.5上创建了一个使用上述类的Web服务.我正在进入[org.xml.sax.SAXParseException: Relative URI "./dtd/Connections.dtd"; can not be resolved without a document URI.]unmarshal线.我尝试在每个relavant文件夹(项目根目录,WebContent,WEB-INF,tomcat工作目录等)中创建./dtd无济于事.
问题1:我在哪里可以找到./dtd,以便在作为tomcat webservice运行时,类可以找到它?我需要做什么tomcat或服务配置才能识别目录?
问题2:为什么该类甚至首先需要dtd文件?它是否具有在dtd-> xsd->类的注释中解组所需的所有信息?我已经阅读了很多关于禁用验证,设置EntityResource和其他解决方案的帖子,但是这个类并不总是作为Web服务部署,我不想有两个代码序列.
使用 Jasper 报告 5.6.1。向以前工作的文本字段 jrxml 添加了一些文本函数(如果长度超过 75 个字符,则只想截断)。适用于 iReport Studio,但不适用于 Java。
<textFieldExpression><![CDATA[IF(LEN($F{AccountName})<75,$F{AccountName},LEFT($F{AccountName},75)+"...")]]></textFieldExpression>
Run Code Online (Sandbox Code Playgroud)
错误信息:
Error occured while trying to fetch the HTML Output from the Jasper Service (Errors were encountered when compiling report expressions class file:
1. The method LEN(String) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<->
2. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
<-->
3. The method LEN(String) is undefined for the type ICC_1422636250096_198427
value = IF(LEN(((java.lang.String)field_AccountName.getOldValue()))<75,((java.lang.String)field_AccountName.getOldValue()),LEFT(((java.lang.String)field_AccountName.getOldValue()),75)+"..."); //$JR_EXPR_ID=9$ …Run Code Online (Sandbox Code Playgroud)