private QName qnameFor (AtomicType type) { if (type.isBuiltInType()) { return qnameFor (((BuiltInAtomicType)type).getQualifiedName()); } return qnameForNameCode(type.getNameCode()); }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, StandardNames.XS_UNTYPED, 0, 0); AtomicType type = (AtomicType)((AtomicValue)item).getItemType(getConfiguration().getTypeHierarchy()); int nameCode = type.getNameCode(); String prefix = pool.getPrefix(nameCode); String localName = pool.getLocalName(nameCode); String uri = pool.getURI(nameCode); if (prefix.length() == 0) { prefix = pool.suggestPrefixForURI(uri); if (prefix == null) { prefix = "p" + uri.hashCode(); } } int nscode = pool.allocateNamespaceCode(prefix, uri); String displayName = prefix + ':' + localName; out.namespace(nscode, 0); out.attribute(xsiType, StandardNames.XS_UNTYPED_ATOMIC, displayName, 0, 0); out.startContent(); out.characters(item.getStringValue(), 0, 0); out.endElement(); } else { ((NodeInfo)item).copy(this, NodeInfo.ALL_NAMESPACES, true, locationId); } }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, StandardNames.XS_UNTYPED, 0, 0); AtomicType type = (AtomicType)((AtomicValue)item).getItemType(getConfiguration().getTypeHierarchy()); int nameCode = type.getNameCode(); String prefix = pool.getPrefix(nameCode); String localName = pool.getLocalName(nameCode); String uri = pool.getURI(nameCode); if (prefix.length() == 0) { prefix = pool.suggestPrefixForURI(uri); if (prefix == null) { prefix = "p" + uri.hashCode(); } } int nscode = pool.allocateNamespaceCode(prefix, uri); String displayName = prefix + ':' + localName; out.namespace(nscode, 0); out.attribute(xsiType, StandardNames.XS_UNTYPED_ATOMIC, displayName, 0, 0); out.startContent(); out.characters(item.getStringValue(), 0, 0); out.endElement(); } else { ((NodeInfo)item).copy(this, NodeInfo.ALL_NAMESPACES, true, locationId); } }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }