本文整理汇总了Java中org.apache.xml.resolver.Catalog.resolveEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Catalog.resolveEntity方法的具体用法?Java Catalog.resolveEntity怎么用?Java Catalog.resolveEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.resolver.Catalog
的用法示例。
在下文中一共展示了Catalog.resolveEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveSchemaLocation
import org.apache.xml.resolver.Catalog; //导入方法依赖的package包/类
private String resolveSchemaLocation(String namespaceOrLocation, Path filePath, File workDir) throws MojoExecutionException, IOException {
for (ArtifactItem artifactItem: artifactItems) {
Catalog catalog = artifactItem.getResolveCatalog();
if (catalog == null) {
continue;
}
String publicId = namespaceOrLocation;
if (publicId.endsWith("#")) {
publicId = publicId.substring(0, publicId.length()-1);
}
String resolvedString = catalog.resolveEntity(filePath.toString(), publicId, publicId);
if (resolvedString != null) {
getLog().debug("-------------------");
getLog().debug("Resolved namespace/schemaLocation "+namespaceOrLocation+" to "+resolvedString+" using catalog "+catalog);
URL resolvedUrl = new URL(resolvedString);
String resolvedPathString = resolvedUrl.getPath();
Path resolvedPath = new File(resolvedPathString).toPath();
Path workDirPath = workDir.toPath();
Path resolvedRelativeToCatalogWorkdir = artifactItem.getWorkDir().toPath().relativize(resolvedPath);
Path fileRelativeToWorkdir = workDirPath.relativize(filePath);
getLog().debug("workDirPath: "+workDirPath);
getLog().debug("resolvedRelativeToCatalogWorkdir: "+resolvedRelativeToCatalogWorkdir+", fileRelativeToWorkdir: "+fileRelativeToWorkdir);
Path relativePath = fileRelativeToWorkdir.getParent().relativize(resolvedRelativeToCatalogWorkdir);
getLog().debug("Rel: "+relativePath);
String unixSeparators = FilenameUtils.separatorsToUnix(relativePath.toString());
getLog().debug("Normalized to use UNIX separators: " + unixSeparators);
return unixSeparators;
}
}
throw new MojoExecutionException("Cannot resolve namespace "+namespaceOrLocation+" in file "+filePath+" using any of the catalogs");
}
示例2: resolveSchemaLocation
import org.apache.xml.resolver.Catalog; //导入方法依赖的package包/类
private String resolveSchemaLocation(String namespaceOrLocation, Path filePath, File workDir) throws MojoExecutionException, IOException {
for (ArtifactItem artifactItem: artifactItems) {
Catalog catalog = artifactItem.getResolveCatalog();
if (catalog == null) {
continue;
}
String publicId = namespaceOrLocation;
if (publicId.endsWith("#")) {
publicId = publicId.substring(0, publicId.length()-1);
}
String resolvedString = catalog.resolveEntity(filePath.toString(), publicId, publicId);
if (resolvedString != null) {
getLog().debug("-------------------");
getLog().debug("Resolved namespace/schemaLocation "+namespaceOrLocation+" to "+resolvedString+" using catalog "+catalog);
URL resolvedUrl = new URL(resolvedString);
String resolvedPathString = resolvedUrl.getPath();
Path resolvedPath = new File(resolvedPathString).toPath();
Path workDirPath = workDir.toPath();
Path resolvedRelativeToCatalogWorkdir = artifactItem.getWorkDir().toPath().relativize(resolvedPath);
Path fileRelativeToWorkdir = workDirPath.relativize(filePath);
getLog().debug("workDirPath: "+workDirPath);
getLog().debug("resolvedRelativeToCatalogWorkdir: "+resolvedRelativeToCatalogWorkdir+", fileRelativeToWorkdir: "+fileRelativeToWorkdir);
Path relativePath = fileRelativeToWorkdir.getParent().relativize(resolvedRelativeToCatalogWorkdir);
getLog().debug("Rel: "+relativePath);
String unixSeparators = FilenameUtils.separatorsToUnix(relativePath.toString());
getLog().debug("Normalized to use UNIX separators: " + unixSeparators);
return unixSeparators;
}
}
throw new MojoExecutionException("Cannot resolve namespace "+namespaceOrLocation+" in file "+filePath+" using any of the catalogs");
}