本文整理汇总了Java中org.apache.xerces.xs.XSModel.getComponents方法的典型用法代码示例。如果您正苦于以下问题:Java XSModel.getComponents方法的具体用法?Java XSModel.getComponents怎么用?Java XSModel.getComponents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xs.XSModel
的用法示例。
在下文中一共展示了XSModel.getComponents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importFromXsd
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
protected void importFromXsd(String text) throws Exception {
XSModel xsModel = new XSParser().parseString(text, "");
XSInstance xsInstance = new XSInstance();
xsInstance.minimumElementsGenerated = 1;
xsInstance.maximumElementsGenerated = 1;
xsInstance.generateOptionalElements = Boolean.TRUE;
XSNamedMap map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
QName rootElement = new QName(map.item(0).getNamespace(), map.item(0).getName(), XMLConstants.DEFAULT_NS_PREFIX);
StringWriter writer = new StringWriter();
XMLDocument sampleXml = new XMLDocument(new StreamResult(writer), true, 4, null);
xsInstance.generate(xsModel, rootElement, sampleXml);
String xml = writer.toString();
listener.onImport(xml);
}
示例2: findElementDeclarationsForName
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
public Set<XSElementDeclaration> findElementDeclarationsForName(String namespace, String name) {
Set<XSElementDeclaration> result=new LinkedHashSet<XSElementDeclaration>();
if (schemaInformation==null) {
log.warn("No SchemaInformation specified, cannot find namespaces for ["+namespace+"]:["+name+"]");
return null;
}
for (XSModel model:schemaInformation) {
XSNamedMap components = model.getComponents(XSConstants.ELEMENT_DECLARATION);
for (int i=0;i<components.getLength();i++) {
XSElementDeclaration item=(XSElementDeclaration)components.item(i);
if ((namespace==null || namespace.equals(item.getNamespace())) && (name==null || name.equals(item.getName()))) {
if (DEBUG) log.debug("name ["+item.getName()+"] found in namespace ["+item.getNamespace()+"]");
result.add(item);
}
}
}
return result;
}
示例3: loadMissingTaxonomyFromKnownSchemas
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
private XbrlTaxonomy loadMissingTaxonomyFromKnownSchemas(String namespace, String name) throws XbrlException, IOException{
XSNamedMap elementDeclarations = null;
if(missingSchemaElementDeclarations.containsKey(namespace))
elementDeclarations = missingSchemaElementDeclarations.get(namespace);
else if(knownSchemaMapping.containsKey(namespace)){
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
schemaLoader.setEntityResolver(loader);
schemaLoader.setFeature("http://apache.org/xml/features/generate-synthetic-annotations", true);
//URI targetLink = loader.getBaseURIResolver().getBaseURI().resolve(knownSchemaMapping.get(namespace));
String cachedFilePath = this.loader.getFileCache().getCachedFilePath(knownSchemaMapping.get(namespace));
String uri = new File(cachedFilePath).toURI().toString();
XSModel xbrlSchemaModel = schemaLoader.loadURI(uri);
schemaToNamespaceMap.put(knownSchemaMapping.get(namespace), namespace);
elementDeclarations = xbrlSchemaModel.getComponents(XSConstants.ELEMENT_DECLARATION);
if(elementDeclarations != null)
missingSchemaElementDeclarations.put(namespace, elementDeclarations);
}
if(elementDeclarations != null){
XSElementDeclaration elementDec = (XSElementDeclaration)elementDeclarations.itemByName(namespace, name);
if(elementDec != null){
XbrlTaxonomy xbrlTaxonomy = parseXbrlTaxonomy(elementDec);
if(xbrlTaxonomy != null){
xbrlConceptCache.put(xbrlTaxonomy.getIdentifier(), xbrlTaxonomy);
return xbrlTaxonomy;
}
}
}
return null;
}
示例4: generateXSDNodeTree
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
public XSDSchema generateXSDNodeTree(String fileName) throws Exception {
this.xsdSchema = new XSDSchema();
XSModel model = initModel(fileName);
XSNamedMap elements = model.getComponents(XSConstants.ELEMENT_DECLARATION);
for (int i = 0; i < elements.getLength(); i++) {
XSElementDecl element = (XSElementDecl) elements.item(i);
analyzeElement(null, null, element);
}
IXSDNode rootNode = findRoot();
xsdSchema.setRoot(rootNode);
return xsdSchema;
}
示例5: main
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args)
{
if (!args[0].equals("--dump"))
{
// Activates the resolver for Drb
try
{
DrbFactoryResolver.setMetadataResolver (
new DrbCortexMetadataResolver (
DrbCortexModel.getDefaultModel ()));
}
catch (IOException e)
{
System.err.println ("Resolver cannot be handled.");
}
process(args[0]);
}
else
{
System.out.println("declare function local:deduplicate($list) {");
System.out.println(" if (fn:empty($list)) then ()");
System.out.println(" else");
System.out.println(" let $head := $list[1],");
System.out.println(" $tail := $list[position() > 1]");
System.out.println(" return");
System.out
.println(" if (fn:exists($tail[ . = $head ])) then " +
"local:deduplicate($tail)");
System.out.println(" else ($head, local:deduplicate($tail))");
System.out.println("};");
System.out.println();
System.out.println("declare function local:values($list) {");
System.out
.println(" fn:string-join(local:deduplicate(" +
"fn:data($list)), ' ')");
System.out.println("};");
System.out.println();
System.out.println("let $doc := !!!! GIVE PATH HERE !!!!");
System.out.println("return\n(\n");
/**
* Open XML Schema
*/
final XSLoader loader = new XMLSchemaLoader();
final XSModel model = loader.loadURI(args[1]);
XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION);
if (map != null)
{
for (int j = 0; j < map.getLength(); j++)
{
dumpElement("", (XSElementDeclaration) map.item(j));
}
}
System.out.println("\n) ^--- REMOVE LAST COMMA !!!");
}
}
示例6: processGroup
import org.apache.xerces.xs.XSModel; //导入方法依赖的package包/类
private TypeDesc processGroup(
XSModelGroup modelGroup,
List<XSModel> models,
Map<String, TypeDesc> jtMap,
Map<String, NamespaceDesc> nsdMap
) {
XSModelGroupDefinition def = null;
for (XSModel xsModel : models) {
XSNamedMap map = xsModel.getComponents(XSConstants.MODEL_GROUP_DEFINITION);
for (int i = 0; i < map.getLength(); i++) {
XSModelGroupDefinition mg = (XSModelGroupDefinition) map.item(i);
final XSModelGroup xsModelGroup = mg.getModelGroup();
if (xsModelGroup == modelGroup || xsModelGroup.toString().equals(modelGroup.toString())) {
def = mg;
break;
}
}
}
if (def == null) {
return null;
}
if (!nsdMap.containsKey(def.getNamespace())) {
Util.log("Namespace desc not found for: " + def);
}
String typeName = toJavaTypeName(def, nsdMap);
final String typeQName = model.toJavaQualifiedTypeName(def, nsdMap, false);
TypeDesc td = jtMap.get(typeQName);
if (td != null) {
if (td.type == TypeDesc.TypeEnum.GROUP_INTERFACE) {
return td;
} else {
Util.logerr("type-group conflict: " + typeName);
return null;
}
} else {
td = new TypeDesc(def.getName(), def.getNamespace(), typeName, TypeDesc.TypeEnum.GROUP_INTERFACE);
}
XSAnnotation ann = def.getAnnotation();
td.documentation = parseAnnotationString(
"Type " + def.getNamespace() + ":" + def.getName() + " documentation",
ann == null ? null : ann.getAnnotationString()
);
td.type = TypeDesc.TypeEnum.GROUP_INTERFACE;
LinkedList<PEntry> plist = new LinkedList<PEntry>();
for (int i = 0; i < def.getModelGroup().getParticles().getLength(); i++) {
XSParticle p = (XSParticle) def.getModelGroup().getParticles().item(i);
plist.add(new PEntry(p, false));
}
processParticles(def, plist, nsdMap, jtMap, td, models, null, null);
jtMap.put(typeQName, td);
return td;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:54,代码来源:XSDModelLoader.java