在记录XML文件的结构时......
我的一位同事在Word表格中做到了这一点.
另一个将元素粘贴到Word文档中,其中包含以下注释:
<learningobject id="{Learning Object Id (same value as the loid tag)}"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.aicpcu.org/schemas/cms_lo.xsd">
<objectRoot>
<v>
<!-- Current version of the object from the repository. !-->
<!-- (Occurance: 1) -->
</v>
<label>
<!-- Name of the object from the repository. !-->
<!-- (Occurance: 0 or 1 or Many) -->
</label>
</objectRoot>
Run Code Online (Sandbox Code Playgroud)
哪种方法更受青睐?有没有更好的办法?
是否有其他选项不需要第三方Schema Documenter工具进行更新?
我开始使用上述答案提出的解决方案中的一些信息:应用程序插件方法
(的build.gradle)
apply plugin: 'application'
mainClassName = "com.mycompany.MyMain"
run {
/* Need to split the space-delimited value in the exec.args */
args System.getProperty("exec.args").split()
}
Run Code Online (Sandbox Code Playgroud)
命令行:
gradle run -Dexec.args="arg1 arg2 arg3"
Run Code Online (Sandbox Code Playgroud)
它的预期用途很好,但似乎有副作用.传递命令行参数以进行运行是有意义的,但我必须为每个任务传递它们,例如:
gradle tasks -Dexec.args="arg1 arg2 arg3"
Run Code Online (Sandbox Code Playgroud)
如果我遗漏了
-Dexec.args="arg1 arg2 arg3"
Run Code Online (Sandbox Code Playgroud)
我明白了
"build failed with an exception"
Where:path\build.gradle line:18 which if where my run{ } is.
Run Code Online (Sandbox Code Playgroud) 想知道我的静态构造函数是否失败并且如果扩展方法仍然有效则抛出异常?记录器旨在帮助检测扩展方法中的问题.如果它们仍然无法工作,我将不得不尝试catch并确保构造函数成功.我希望能够让它抛出异常,因为希望调用代码可以记录错误.(这只是我正在考虑的示例代码)
public static class Extensions
{
private static readonly log4net.ILog log;
private const TIME_TO_CHECK;
static Extensions()
{
log = log4net.LogManager.GetLogger (System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //could maybe throw exception
TIME_TO_CHECK = readInFromFile(); //could maybe throw exception }
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek) {
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0) {
diff += 7;
}
return dt.AddDays(-1 * diff).Date;
}
}
Run Code Online (Sandbox Code Playgroud)
我做了搜索(希望这不是重复)并发现从静态构造函数中抛出异常通常不是很好.在大多数情况下,我认为这些类是可以实例化的,而不仅仅是所有扩展方法.
所以我已经能够将一些类添加到本体中并将它们保存到文件中。现在我希望能够向我的类添加数据类型,但我对如何做这可能非常简单的事情感到困惑。这就是我一直在尝试的:
OWLClass currentClass =df.getOWLClass(IRI.create("Base"));
OWLDataProperty owlAttr = df.getOWLDataProperty(IRI.create("#" + "name");
OWLLiteralImplString lit = new OWLLiteralImplString("test"); //This is probably on the wrong path
DefaultPrefixManager defaultPrefixManager = new DefaultPrefixManager();
OWLDatatype datatype = df.getOWLDatatype("xsd:string",defaultPrefixManager);
OWLAxiom axiom = df.getOWLDatatypeDefinitionAxiom(datatype, ?); //having trouble find a range.
Run Code Online (Sandbox Code Playgroud)
编辑 #1 所以我有点担心我的问题不清楚。我想做的事情与 Java 中的类似:
public class Car{
}
Run Code Online (Sandbox Code Playgroud)
我目前可以使用 owlapi 创建一个类,但我想要做的就像向我的 Java 类添加一个数据成员:
public class Car{
public String manufacturer;
}
Run Code Online (Sandbox Code Playgroud)
使用Protege我可以生成这个,我认为这就是我想要用 owlapi 生成的:
<!-- http://www.co-ode.org/ontologies/ont.owl#manufacturer -->
<DatatypeProperty rdf:about="http://www.co-ode.org/ontologies/ont.owl#manufacturer">
<rdfs:domain rdf:resource="http://www.co-ode.org/ontologies/ont.owl#Car"/>
<rdfs:range rdf:resource="&xsd;string"/>
</DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
// …
Run Code Online (Sandbox Code Playgroud)