我正在尝试在我的Java应用程序中显示HTML,该应用程序在我的HTML中包含链接的样式表.
我正在使用Java中的XSLT将我的XML转换为HTML.我想要包含样式表,以便我可以轻松设置html输出的样式.但是,样式表被忽略,html正常输出.
为此,我使用的是JEditorPane和HTMLEditorKit.我在Dev Daily上找到了一些示例代码来执行此操作.
我的样式表坐在我的本地硬盘上,我想知道是否有人知道我如何使用它?
我有以下代码:
JEditorPane jEditorPane = new JEditorPane();
jEditorPane.setEditable( false );
HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);
try {
kit.getStyleSheet().importStyleSheet( new URL( "file://D:\\mycssfile.css" ) );
} catch( MalformedURLException ex ) {
}
Document doc = kit.createDefaultDocument();
jEditorPane.setDocument(doc);
jEditorPane.setText(html);
Run Code Online (Sandbox Code Playgroud)
在我从xsl输出的html中,使用以下内容链接css - 我得到包含或排除的相同结果:
<link rel="stylesheet" type="text/css" href="mycss.css" />
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
干杯,
Andez
我正在使用JOptionPane.showConfirmDialog在Java中显示一个确认对话框.该对话框向用户显示"是否确认".这称为如下:
int result = JOptionPane.showConfirmDialog(sessionObjects.getActiveComponent(),
"Are you sure you want to exit?", "My App", JOptionPane.YES_NO_OPTION);
Run Code Online (Sandbox Code Playgroud)
问题是这是一个简单的确认,用户可以按y是和n否吗?目前用户必须点击按钮?
谢谢,
Andez
好的,我正在运行单元测试,以查看Exception.Data属性是否包含针对特定命名键的特定值.
Exception.Data的类型为IDictionary.IDictionary只有2个重载,我无法看到验证字典中的内容的方法.
我有以下代码抛出异常:
public class MyClass
{
public void ThrowMyException()
{
throw new MyException();
}
}
public class MyException : Exception
{
public MyException()
{
this.Data.Add("MyKey1", 212);
this.Data.Add("MyKey2", 2121);
}
}
Run Code Online (Sandbox Code Playgroud)
然后进行测试以验证MyKey1 = 212和MyKey2 = 2121:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
MyClass classUnderTest = new MyClass();
Action test = () =>
{
classUnderTest.ThrowMyException();
};
test.ShouldThrow<MyException>() //.And.Data.Keys.Should().Contain("")
}
}
Run Code Online (Sandbox Code Playgroud)
我想测试数据包含值为212的MyKey1和值为2121的MyKey2.
我在XML -1.8959581529998104E-4中有以下值.我想将其格式化为应该使用XSL给出的确切数字-0.000189595815299981.
format-number(-1.8959581529998104E-4,'0.000000; -0.000000')给了我NaN.
有任何想法吗?
干杯
Andez
在格式化数字时,XSL 中是否内置了任何区域化支持?
目前,我的底层 XML 包含英国/美国格式的数字,例如 54321.12345。我可以对此进行选择总和,以相同的格式给出总计。我可以使用 format-number(54321.12345, '###,###.#####') 格式化数字,得到 54,321.12345。
但是,当我希望它在我的计算机上的不同区域设置上运行时,例如将逗号分隔符设置为“.”的中欧国家。小数点分隔符为“,”我想以这种方式格式化我的数字,得到 54.321,12345。
在 XSL 中有没有好的方法可以做到这一点?
谢谢,
安德兹
I am using Wix 3.6 to create a setup. I am still learning as I go along. The information out there is still scattered around. I am just waiting for my Wix Developer Guide book arriving.
I currently have a custom UI dialog where the user enters some application configuration. Part of that configuration is to specify a log folder. This at present this just sets a property [LogFolder]. This is defaulted to something like D:\Logs.
I want the installer …
我是ORM的忠实粉丝,特别是涉及.NET with Entity Framework并使用LINQ使您的数据访问变得不那么繁琐和愉快.
但是,我目前正在研究Java,特别是关注ORM.我已经尝试过针对我们的SQL Server数据库的nHybernate - 并且由于某些表上没有键(唯一约束),我开始关注JOOQ.
我已经设法从SQL Server数据库生成我的Java类 - 但并非没有错误 - 使用JOOQ(v3.2.0).
根据这个页面JOOQ Connections,它提到了一个类org.jooq.util.sqlserver.SQLServerDatabase.但是当我在配置中生成这个时,我得到了class not found异常并且没有生成任何内容.我不得不使用org.jooq.util.jdbc.JDBCDatabase来生成我的代码.
这是我的配置文件(myjooqdbconfig.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.2.0.xsd">
<jdbc>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://MYSERVER:1433;DatabaseName=MYDB</url>
<user>MYUSER</user>
<password>PWD</password>
</jdbc>
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<database>
<name>org.jooq.util.jdbc.JDBCDatabase</name>
<inputSchema>dbo</inputSchema>
<includes>.*</includes>
<excludes></excludes>
</database>
<target>
<packageName>com.quorum.sentinel.dataAccess</packageName>
<directory>F:\Libraries\jooq\jOOQ-3.2.0\lib\gen</directory>
</target>
</generator>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在找不到类的异常的情况下,我使用Java Decompiler查看了JAR文件jooq-meta-3.2.0.jar,它将显示这些类所在的位置.我看不到org.jooq.util.sqlserver.SQLServerDatabase类的定义.

我正在编译:
java -classpath jooq-3.2.0.jar; jooq-meta-3.2.0.jar; jooq-codegen-3.2.0.jar; sqljdbc4.jar;.org.jooq.util.GenerationTool /myjooqdbconfig.xml
这个org.jooq.util.sqlserver.SQLServerDatabase定义是否存在于任何JAR中?
另外,从上面的配置生成代码后,似乎需要很长时间,并且似乎处于某种循环中.
查看dbo下的生成文件 - Keys/Tables/Dbo,当我将文件复制到Netbeans项目(很多错误)时,我注意到了我的表的重复名称.我删除了重复项,到目前为止很好,我可以在下面的代码中从数据库中读取各种表:
public static void main(String[] args) {
Connection conn = null;
String userName = "MYUSER";
String password = "PWD"; …Run Code Online (Sandbox Code Playgroud) 给定以下HTML,是否可以使用CSS选择器将标签内的文本定位?
<fieldset class="sl">
<legend>
Text Inputs
</legend>
<label>
Text Input:
<input type="text" />
</label>
<label>
Read-only Text Input:
<input type="text" readonly value="this is read-only" />
</label>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
因此,在上面,我要定位“文本输入”或“只读文本输入:”并设置宽度以对齐文本框的左侧位置。
我能想到的唯一有效的方法是将文本包裹在一个范围内。
<label>
<span>Text Input:</span>
<input type="text" />
</label>
Run Code Online (Sandbox Code Playgroud)
使用CSS选择器:
fieldset.sl label span {
width: 200px;
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
仅供参考-我正在考虑使用CSS来兼顾两者,在CSS的同一行和输入上方的单独行之间切换-无需修改html结构-只是对fieldset类进行了调整,例如以下使用标签中的文本包裹在一个跨度中。
我希望能够使用 Roslyn 代码分析从程序集中的 AssemblyInfo.cs 文件中读取一些程序集属性。
因此给出以下示例:
using System;
using System.Collections.Generic;
using System.Text;
[assembly: Helloworld.TestAttribute1("Test1")]
[assembly: Helloworld.TestAttribute1(TheValue = "Test1", IgnoreThis = "I dont want this one!")]
namespace Helloworld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class TestAttribute1 : Attribute
{
public TestAttribute1()
{
}
public TestAttribute1(string theValue)
{
this.TheValue = theValue;
}
public string TheValue { get; set; }
public string IgnoreThis { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能够提取 type …
在创建新的 Visual Studio 解决方案时,我想使用Directory.Build.props来控制所有 c# 项目的 c# 版本号,而无需单独设置它们。
但是,混合使用 c# 和 f# 文件夹会导致编译错误。
Severity Code Description Project File Line Suppression State
Error FS0246 Unrecognized value '8.0' for --langversion use --langversion:? for complete list FSharpLib C:\source\solution\FSharpLib\FSC 1 Active
Run Code Online (Sandbox Code Playgroud)
这是演示该问题的最小解决方案。在一个真正的解决方案中,显然有更多的项目。
\solution
\solution\Directory.Build.props
\solution\CSharpLib
\solution\FSharpLib
<Project>
<PropertyGroup>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
FSharpLib
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library.fs" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
是否有可能有c sharp和f sharp项目并排用Directory.Build.props在根文件夹只适用于 …
c# ×3
java ×3
css ×2
format ×2
html ×2
numbers ×2
xslt ×2
.net ×1
attributes ×1
f# ×1
installation ×1
jooq ×1
joptionpane ×1
msbuild ×1
roslyn ×1
shortcut ×1
sql-server ×1
swing ×1
unit-testing ×1
wix ×1