当前位置: 首页>>代码示例>>Java>>正文


Java NamespaceMap类代码示例

本文整理汇总了Java中org.apache.ws.commons.schema.utils.NamespaceMap的典型用法代码示例。如果您正苦于以下问题:Java NamespaceMap类的具体用法?Java NamespaceMap怎么用?Java NamespaceMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamespaceMap类属于org.apache.ws.commons.schema.utils包,在下文中一共展示了NamespaceMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNamespaceContext

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
/**
 * Adds the COXB namespace and associated prefixes to the XML schema.
 */
protected void addNamespaceContext() {
    NamespaceMap prefixmap = new NamespaceMap();
    NamespacePrefixList npl = getXsd().getNamespaceContext();
    if (npl == null) {
        /* We get an NPE if we don't add this. */
        prefixmap.add("", XMLConstants.W3C_XML_SCHEMA_NS_URI);
    } else {
        for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
            prefixmap.add(npl.getDeclaredPrefixes()[i], npl
                    .getNamespaceURI(
                    npl.getDeclaredPrefixes()[i]));
        }
    }
    prefixmap.add(getCOXBNamespacePrefix(), getCOXBNamespace());
    getXsd().setNamespaceContext(prefixmap);

}
 
开发者ID:legsem,项目名称:legstar-cob2xsd,代码行数:21,代码来源:XsdAnnotationEmitter.java

示例2: addNamespaceContext

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
/**
 * Adds the COXB namespace and associated prefixes to the XML schema.
 */
protected void addNamespaceContext() {
    NamespaceMap prefixmap = new NamespaceMap();
    NamespacePrefixList npl = getXsd().getNamespaceContext();
    if (npl == null) {
        /* We get an NPE if we don't add this. */
        prefixmap.add("", XMLConstants.W3C_XML_SCHEMA_NS_URI);
    } else {
        for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
            prefixmap.add(npl.getDeclaredPrefixes()[i],
                    npl.getNamespaceURI(npl.getDeclaredPrefixes()[i]));
        }
    }
    prefixmap.add(getCOXBNamespacePrefix(), getCOXBNamespace());
    getXsd().setNamespaceContext(prefixmap);

}
 
开发者ID:legsem,项目名称:legstar-core2,代码行数:20,代码来源:XsdAnnotationEmitter.java

示例3: addImport

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
protected void addImport(XmlSchema xmlSchema, QName schemaTypeName) {
    NamespacePrefixList map = xmlSchema.getNamespaceContext();
    if (map == null ||
            ((map instanceof NamespaceMap) && ((NamespaceMap) map).values() == null) ||
            schemaTypeName == null) {
        return;
    }
    if (map instanceof NamespaceMap && !((NamespaceMap) map).values().
            contains(schemaTypeName.getNamespaceURI())) {
        XmlSchemaImport importElement = new XmlSchemaImport();
        importElement.setNamespace(schemaTypeName.getNamespaceURI());
        xmlSchema.getItems().add(importElement);
        ((NamespaceMap) xmlSchema.getNamespaceContext()).
                put(generatePrefix(), schemaTypeName.getNamespaceURI());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:DefaultSchemaGenerator.java

示例4: createSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
public static XmlSchema createSchema(String prefix, String targetNamespace, String elementFormDefault, String attributeFormDefault) {
	NamespaceMap nsMap = new NamespaceMap();
	nsMap.add("xsd", Constants.URI_2001_SCHEMA_XSD);
	nsMap.add(prefix, targetNamespace);
	
	XmlSchemaCollection xmlSchemaCollection = createSchemaCollection(nsMap);
	
	XmlSchema xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
	xmlSchema.setNamespaceContext(nsMap);
	xmlSchema.setElementFormDefault(new XmlSchemaForm(elementFormDefault));
	xmlSchema.setAttributeFormDefault(new XmlSchemaForm(attributeFormDefault));
	return xmlSchema;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:SchemaUtils.java

示例5: getNamespaceMap

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
public static NamespaceMap getNamespaceMap(XmlSchema xmlSchema) {
	NamespaceMap namespacesMap = new NamespaceMap();
	NamespacePrefixList namespacePrefixList = xmlSchema.getNamespaceContext();
	if (namespacePrefixList != null) {
		String[] prefixes = namespacePrefixList.getDeclaredPrefixes();
		for (int i=0; i<prefixes.length; i++) {
			String prefix = prefixes[i];
			String ns = namespacePrefixList.getNamespaceURI(prefix);
			namespacesMap.add(prefix, ns);
		}
	}
	return namespacesMap;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:SchemaUtils.java

示例6: createXmlSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
/**
 * Create an empty XML Schema.
 * <p>
 * If no targetNamespace, make sure there is no default namespace otherwise
 * our complex types would be considered part of that default namespace
 * (usually XML Schema namespace).
 * 
 * @param encoding the character set used to encode this XML Schema
 * @return a new empty XML schema using the model
 */
protected XmlSchema createXmlSchema(final String encoding) {
    XmlSchema xsd = new XmlSchema(getModel().getTargetNamespace(),
            new XmlSchemaCollection());
    if (getModel().getTargetNamespace() != null) {
        xsd.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
    }
    xsd.setAttributeFormDefault(null);
    xsd.setInputEncoding(encoding);
    if (getModel().getTargetNamespace() == null) {
        NamespaceMap prefixmap = new NamespaceMap();
        NamespacePrefixList npl = xsd.getNamespaceContext();
        if (npl == null) {
            prefixmap.add("xsd", XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } else {
            for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
                String prefix = npl.getDeclaredPrefixes()[i];
                String namespace = npl.getNamespaceURI(prefix);
                if (namespace.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
                    if (prefix.equals("")) {
                        prefix = "xsd";
                    }
                }
                prefixmap.add(prefix, namespace);
            }
        }
        xsd.setNamespaceContext(prefixmap);
    }
    return xsd;
}
 
开发者ID:legsem,项目名称:legstar-cob2xsd,代码行数:40,代码来源:Cob2Xsd.java

示例7: createBridgeXsElement

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) {
    XmlSchemaElement el = null;
    SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI());
    if (schemaInfo != null) {
        el = schemaInfo.getElementByQName(qn);
        if (el == null) {
            el = createXsElement(schemaInfo.getSchema(), part, typeName, schemaInfo);

        } else if (!typeName.equals(el.getSchemaTypeName())) {
            throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG,
                                        qn, typeName, el.getSchemaTypeName()));
        }
        return;
    }

    XmlSchema schema = schemas.newXmlSchemaInCollection(qn.getNamespaceURI());
    if (qualifiedSchemas) {
        schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
    }
    schemaInfo = new SchemaInfo(qn.getNamespaceURI(), qualifiedSchemas, false);
    schemaInfo.setSchema(schema);

    el = createXsElement(schema, part, typeName, schemaInfo);

    NamespaceMap nsMap = new NamespaceMap();
    nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace());
    nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
    schema.setNamespaceContext(nsMap);

    serviceInfo.addSchema(schemaInfo);
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:32,代码来源:JAXBSchemaInitializer.java

示例8: createXmlSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
/**
 * Create an empty XML Schema.
 * <p/>
 * If no targetNamespace, make sure there is no default namespace otherwise
 * our complex types would be considered part of that default namespace
 * (usually XML Schema namespace).
 * 
 * @param encoding the character set used to encode this XML Schema
 * @param targetNamespace the target namespace to use (null for no namespace)
 * @return a new empty XML schema using the model
 */
protected XmlSchema createXmlSchema(final String encoding, final String targetNamespace) {
    XmlSchema xsd = new XmlSchema(targetNamespace,
            new XmlSchemaCollection());
    if (targetNamespace != null) {
        xsd.setElementFormDefault(XmlSchemaForm.QUALIFIED);
    }
    xsd.setAttributeFormDefault(null);
    xsd.setInputEncoding(encoding);
    if (targetNamespace == null) {
        NamespaceMap prefixmap = new NamespaceMap();
        NamespacePrefixList npl = xsd.getNamespaceContext();
        if (npl == null) {
            prefixmap.add("xsd", XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } else {
            for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
                String prefix = npl.getDeclaredPrefixes()[i];
                String namespace = npl.getNamespaceURI(prefix);
                if (namespace.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
                    if (prefix.equals("")) {
                        prefix = "xsd";
                    }
                }
                prefixmap.add(prefix, namespace);
            }
        }
        xsd.setNamespaceContext(prefixmap);
    }
    return xsd;
}
 
开发者ID:legsem,项目名称:legstar-core2,代码行数:41,代码来源:Cob2Xsd.java

示例9: getXmlSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
private XmlSchema getXmlSchema(String targetNamespace) {
    XmlSchema xmlSchema;

    if ((xmlSchema = (XmlSchema) schemaMap.get(targetNamespace)) == null) {
        String targetNamespacePrefix;

        if ( targetNamespace.equals(schemaTargetNameSpace) &&
                schema_namespace_prefix != null ) {
            targetNamespacePrefix = schema_namespace_prefix;
        } else {
            targetNamespacePrefix = generatePrefix();
        }


        xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
        xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
        xmlSchema.setElementFormDefault(getElementFormDefaultSetting());


        targetNamespacePrefixMap.put(targetNamespace, targetNamespacePrefix);
        schemaMap.put(targetNamespace, xmlSchema);

        NamespaceMap prefixmap = new NamespaceMap();
        prefixmap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX, URI_2001_SCHEMA_XSD);
        prefixmap.put(targetNamespacePrefix, targetNamespace);
        xmlSchema.setNamespaceContext(prefixmap);
    }
    return xmlSchema;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:30,代码来源:SchemaGenerator.java

示例10: addImport

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
private void addImport(XmlSchema xmlSchema, QName schemaTypeName) {
    if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().
            contains(schemaTypeName.getNamespaceURI())) {
        XmlSchemaImport importElement = new XmlSchemaImport();
        importElement.setNamespace(schemaTypeName.getNamespaceURI());
        xmlSchema.getItems().add(importElement);
        ((NamespaceMap) xmlSchema.getNamespaceContext()).
                put(generatePrefix(), schemaTypeName.getNamespaceURI());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:11,代码来源:SchemaGenerator.java

示例11: getXmlSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
protected XmlSchema getXmlSchema(String targetNamespace) {
    XmlSchema xmlSchema;

    if ((xmlSchema = schemaMap.get(targetNamespace)) == null) {
        String targetNamespacePrefix;

        if (targetNamespace.equals(schemaTargetNameSpace) &&
                schema_namespace_prefix != null) {
            targetNamespacePrefix = schema_namespace_prefix;
        } else {
            targetNamespacePrefix = generatePrefix();
        }


        xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
        xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
        xmlSchema.setElementFormDefault(getElementFormDefaultSetting());


        targetNamespacePrefixMap.put(targetNamespace, targetNamespacePrefix);
        schemaMap.put(targetNamespace, xmlSchema);

        NamespaceMap prefixmap = new NamespaceMap();
        prefixmap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX, URI_2001_SCHEMA_XSD);
        prefixmap.put(targetNamespacePrefix, targetNamespace);
        xmlSchema.setNamespaceContext(prefixmap);
    }
    return xmlSchema;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:30,代码来源:DefaultSchemaGenerator.java

示例12: getXmlSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
@Override
protected XmlSchema getXmlSchema(String targetNamespace) {
    XmlSchema xmlSchema;

    if ((xmlSchema = schemaMap.get(targetNamespace)) == null) {
        String targetNamespacePrefix;

        if (targetNamespace.equals(schemaTargetNameSpace) &&
                schema_namespace_prefix != null) {
            targetNamespacePrefix = schema_namespace_prefix;
        } else {
            targetNamespacePrefix = generatePrefix();
        }


        xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
        xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
        xmlSchema.setElementFormDefault(getElementFormDefaultSetting());


        targetNamespacePrefixMap.put(targetNamespace, targetNamespacePrefix);
        schemaMap.put(targetNamespace, xmlSchema);

        NamespaceMap prefixmap = new NamespaceMap();
        prefixmap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX, URI_2001_SCHEMA_XSD);
        prefixmap.put(targetNamespacePrefix, targetNamespace);
        xmlSchema.setNamespaceContext(prefixmap);
    }
    return xmlSchema;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:31,代码来源:DocLitBareSchemaGenerator.java

示例13: addNameSpaces

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
private XmlSchema addNameSpaces(int i) {
	XmlSchema schema = (XmlSchema) schemaList.get(i);
	NamespaceMap map = (NamespaceMap) namespaceMap.clone();
	NamespacePrefixList namespaceContext = schema.getNamespaceContext();
	String prefixes[] = namespaceContext.getDeclaredPrefixes();
	for (int j = 0; j < prefixes.length; j++) {
		String prefix = prefixes[j];
		map.add(prefix, namespaceContext.getNamespaceURI(prefix));
	}
	schema.setNamespaceContext(map);
	return schema;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:AxisService.java

示例14: initNSMap

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
private void initNSMap() {
    nsMap = new NamespaceMap();
    NamespacePrefixList nsCtx = schemaColl.getNamespaceContext();
    populateNSMap(nsCtx);

    XmlSchema[] xmlSchemas = schemaColl.getXmlSchemas();
    if (xmlSchemas != null && xmlSchemas.length > 0) {
        for (XmlSchema schema : xmlSchemas) {
            nsCtx = schema.getNamespaceContext();
            populateNSMap(nsCtx);
        }
    }
    logger.debug(MessageFormat.format("namespace map contains {0} entries", nsMap.size()));
}
 
开发者ID:mkris,项目名称:xsd2xml,代码行数:15,代码来源:SchemaTypeXmlGenerator.java

示例15: retrieveSchema

import org.apache.ws.commons.schema.utils.NamespaceMap; //导入依赖的package包/类
/**
 * Retrieve the XML schema with the given namespace.
 * @param cparams Common parameters used in the schema generator
 * @param namespace The target namespace of the XML schema
 * @return The XML schema object
 */
private static XmlSchema retrieveSchema(CommonParams cparams, String namespace) {
	Map<String, XmlSchema> schemaMap = cparams.getSchemaMap();
	if (!schemaMap.containsKey(namespace)) {
		XmlSchema schema = new XmlSchema(namespace, cparams.getXmlSchemaCollection());
		schema.setNamespaceContext(new NamespaceMap());
		schemaMap.put(namespace, schema);
		schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
		schema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED));
	}
	return schemaMap.get(namespace);
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:18,代码来源:DataServiceDocLitWrappedSchemaGenerator.java


注:本文中的org.apache.ws.commons.schema.utils.NamespaceMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。