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


Java XMLObject.getSchemaType方法代码示例

本文整理汇总了Java中org.opensaml.xml.XMLObject.getSchemaType方法的典型用法代码示例。如果您正苦于以下问题:Java XMLObject.getSchemaType方法的具体用法?Java XMLObject.getSchemaType怎么用?Java XMLObject.getSchemaType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opensaml.xml.XMLObject的用法示例。


在下文中一共展示了XMLObject.getSchemaType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkXMLObjectIsTarget

import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
 * Checks to make sure the given XMLObject's schema type or element QName matches the target parameters given at
 * marshaller construction time.
 * 
 * @param xmlObject the XMLObject to marshall
 * 
 * @throws MarshallingException thrown if the given object is not or the required type
 */
protected void checkXMLObjectIsTarget(XMLObject xmlObject) throws MarshallingException {
    if (targetQName == null) {
        log.trace("Targeted QName checking is not available for this marshaller, XMLObject {} was not verified",
                xmlObject.getElementQName());
        return;
    }

    log.trace("Checking that {} meets target criteria", xmlObject.getElementQName());
    QName type = xmlObject.getSchemaType();
    if (type != null && type.equals(targetQName)) {
        log.trace("{} schema type matches target", xmlObject.getElementQName());
        return;
    } else {
        QName elementQName = xmlObject.getElementQName();
        if (elementQName.equals(targetQName)) {
            log.trace("{} element QName matches target", xmlObject.getElementQName());
            return;
        }
    }

    String errorMsg =
            "This marshaller only operations on " + targetQName + " elements not " + xmlObject.getElementQName();
    log.error(errorMsg);
    throw new MarshallingException(errorMsg);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AbstractXMLObjectMarshaller.java

示例2: performValidation

import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
 * Validates the given XMLObject. Does NOT validate its children.
 * 
 * @param xmlObject the XMLObject to validate.
 * 
 * @throws ValidationException thrown if the XMLObject does not validate
 */
private void performValidation(XMLObject xmlObject) throws ValidationException {
    QName schemaType = xmlObject.getSchemaType();
    if (schemaType != null) {
        log.debug("Validating XMLObject {} against validators registered under its schema type {}", xmlObject
                .getElementQName(), schemaType);
        performValidation(schemaType, xmlObject);
    }

    log.debug("Validating XMLObject {} against validators registered under its element QName", xmlObject
            .getElementQName());
    performValidation(xmlObject.getElementQName(), xmlObject);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ValidatorSuite.java

示例3: marshallSchemaInstanceAttributes

import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
 * Creates the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes for an XMLObject.
 * 
 * @param xmlObject the XMLObject
 * @param domElement the DOM element the namespaces will be added to
 * 
 * @throws MarshallingException thrown if the schema type information is invalid
 */
protected void marshallSchemaInstanceAttributes(XMLObject xmlObject, Element domElement)
        throws MarshallingException {

    if (!DatatypeHelper.isEmpty(xmlObject.getSchemaLocation())) {
        log.trace("Setting xsi:schemaLocation for XMLObject {} to {}", xmlObject.getElementQName(),
                xmlObject.getSchemaLocation());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":schemaLocation",
                xmlObject.getSchemaLocation());
    }

    if (!DatatypeHelper.isEmpty(xmlObject.getNoNamespaceSchemaLocation())) {
        log.trace("Setting xsi:noNamespaceSchemaLocation for XMLObject {} to {}", xmlObject.getElementQName(),
                xmlObject.getNoNamespaceSchemaLocation());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":noNamespaceSchemaLocation",
                xmlObject.getNoNamespaceSchemaLocation());
    }

    if (xmlObject.isNilXSBoolean() != null && xmlObject.isNil()) {
        log.trace("Setting xsi:nil for XMLObject {} to true", xmlObject.getElementQName());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":nil", xmlObject.isNilXSBoolean()
                .toString());
    }

    QName type = xmlObject.getSchemaType();
    if (type == null) {
        return;
    }

    log.trace("Setting xsi:type attribute with for XMLObject {}", xmlObject.getElementQName());
    String typeLocalName = DatatypeHelper.safeTrimOrNullString(type.getLocalPart());
    String typePrefix = DatatypeHelper.safeTrimOrNullString(type.getPrefix());

    if (typeLocalName == null) {
        throw new MarshallingException("The type QName on XMLObject " + xmlObject.getElementQName()
                + " may not have a null local name");
    }

    if (type.getNamespaceURI() == null) {
        throw new MarshallingException("The type URI QName on XMLObject " + xmlObject.getElementQName()
                + " may not have a null namespace URI");
    }

    String attributeValue;
    if (typePrefix == null) {
        attributeValue = typeLocalName;
    } else {
        attributeValue = typePrefix + ":" + typeLocalName;
    }

    domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":type", attributeValue);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:60,代码来源:AbstractXMLObjectMarshaller.java


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