com.sun.xml.internal.bind.v2.WellKnownNamespace Java Examples
The following examples show how to use
com.sun.xml.internal.bind.v2.WellKnownNamespace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MTOMXmlOutput.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException { if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) { Base64Data b64d = (Base64Data) value; String cid; if(b64d.hasData()) cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName); else cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.getDataHandler(),nsUri,localName); if(cid!=null) { nsContext.getCurrent().push(); int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false); beginStartTag(prefix,"Include"); attribute(-1,"href",cid); endStartTag(); endTag(prefix,"Include"); nsContext.getCurrent().pop(); return; } } next.text(value, needsSeparatingWhitespace); }
Example #2
Source File: AnyTypeBeanInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void serializeAttributes(Object element, XMLSerializer target) throws SAXException { NamedNodeMap al = ((Element)element).getAttributes(); int len = al.getLength(); for( int i=0; i<len; i++ ) { Attr a = (Attr)al.item(i); // work defensively String uri = a.getNamespaceURI(); if(uri==null) uri=""; String local = a.getLocalName(); String name = a.getName(); if(local==null) local = name; if (uri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE) && ("nil".equals(local))) { isNilIncluded = true; } if(name.startsWith("xmlns")) continue;// DOM reports ns decls as attributes target.attribute(uri,local,a.getValue()); } }
Example #3
Source File: SimpleTypeBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Returns true if the given simple type can be mapped to a * type-safe enum class. * * <p> * JAXB spec places a restrictrion as to what type can be * mapped to a type-safe enum. This method enforces this * constraint. */ public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) { do { if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) { // type must be derived from one of these types String localName = type.getName(); if( localName!=null ) { if( localName.equals("anySimpleType") ) return false; // catch all case if( localName.equals("ID") || localName.equals("IDREF") ) return false; // not ID/IDREF // other allowed list if( builtinTypeSafeEnumCapableTypes.contains(localName) ) return true; } } type = type.getSimpleBaseType(); } while( type!=null ); return false; }
Example #4
Source File: BindInfo.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void addTo(BindInfo bi) { if(contents==null) return; for (Object o : contents) { if(o instanceof BIDeclaration) bi.addDecl((BIDeclaration)o); // this is really PITA! I can't get the source location if(o instanceof DomHandlerEx.DomAndLocation) { DomHandlerEx.DomAndLocation e = (DomHandlerEx.DomAndLocation)o; String nsUri = e.element.getNamespaceURI(); if(nsUri==null || nsUri.equals("") || nsUri.equals(WellKnownNamespace.XML_SCHEMA)) continue; // this is definitely not a customization bi.addDecl(new BIXPluginCustomization(e.element,e.loc)); } } }
Example #5
Source File: SimpleTypeBuilder.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns true if the given simple type can be mapped to a * type-safe enum class. * * <p> * JAXB spec places a restrictrion as to what type can be * mapped to a type-safe enum. This method enforces this * constraint. */ public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) { do { if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) { // type must be derived from one of these types String localName = type.getName(); if( localName!=null ) { if( localName.equals("anySimpleType") ) return false; // catch all case if( localName.equals("ID") || localName.equals("IDREF") ) return false; // not ID/IDREF // other allowed list if( builtinTypeSafeEnumCapableTypes.contains(localName) ) return true; } } type = type.getSimpleBaseType(); } while( type!=null ); return false; }
Example #6
Source File: MTOMDecorator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void startElement(TagName tagName) throws SAXException { if(tagName.local.equals("Include") && tagName.uri.equals(WellKnownNamespace.XOP)) { // found xop:Include String href = tagName.atts.getValue("href"); DataHandler attachment = au.getAttachmentAsDataHandler(href); if(attachment==null) { // report an error and ignore parent.getEventHandler().handleEvent(null); // TODO } base64data.set(attachment); next.text(base64data); inXopInclude = true; followXop = true; } else next.startElement(tagName); }
Example #7
Source File: XMLConvertor.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
private void initialize(String schema) throws JAXBException { um = context.createUnmarshaller(); um.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/xml"); m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_ENCODING, "utf-8"); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new NamespacePrefixMapper() { @Override public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { if(namespaceUri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE)) { return "xsi"; } else return "m2m"; } }); String schemaLocation = schema; if(schemaLocation != null) { m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.onem2m.org/xml/protocols " + schemaLocation); } m.setProperty(MarshallerProperties.MEDIA_TYPE, "application/xml"); }
Example #8
Source File: MTOMXmlOutput.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException { if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) { Base64Data b64d = (Base64Data) value; String cid; if(b64d.hasData()) cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName); else cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.getDataHandler(),nsUri,localName); if(cid!=null) { nsContext.getCurrent().push(); int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false); beginStartTag(prefix,"Include"); attribute(-1,"href",cid); endStartTag(); endTag(prefix,"Include"); nsContext.getCurrent().pop(); return; } } next.text(value, needsSeparatingWhitespace); }
Example #9
Source File: AnyTypeBeanInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void serializeAttributes(Object element, XMLSerializer target) throws SAXException { NamedNodeMap al = ((Element)element).getAttributes(); int len = al.getLength(); for( int i=0; i<len; i++ ) { Attr a = (Attr)al.item(i); // work defensively String uri = a.getNamespaceURI(); if(uri==null) uri=""; String local = a.getLocalName(); String name = a.getName(); if(local==null) local = name; if (uri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE) && ("nil".equals(local))) { isNilIncluded = true; } if(name.startsWith("xmlns")) continue;// DOM reports ns decls as attributes target.attribute(uri,local,a.getValue()); } }
Example #10
Source File: BindInfo.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void addTo(BindInfo bi) { if(contents==null) return; for (Object o : contents) { if(o instanceof BIDeclaration) bi.addDecl((BIDeclaration)o); // this is really PITA! I can't get the source location if(o instanceof DomHandlerEx.DomAndLocation) { DomHandlerEx.DomAndLocation e = (DomHandlerEx.DomAndLocation)o; String nsUri = e.element.getNamespaceURI(); if(nsUri==null || nsUri.equals("") || nsUri.equals(WellKnownNamespace.XML_SCHEMA)) continue; // this is definitely not a customization bi.addDecl(new BIXPluginCustomization(e.element,e.loc)); } } }
Example #11
Source File: SimpleTypeBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns true if the given simple type can be mapped to a * type-safe enum class. * * <p> * JAXB spec places a restrictrion as to what type can be * mapped to a type-safe enum. This method enforces this * constraint. */ public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) { do { if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) { // type must be derived from one of these types String localName = type.getName(); if( localName!=null ) { if( localName.equals("anySimpleType") ) return false; // catch all case if( localName.equals("ID") || localName.equals("IDREF") ) return false; // not ID/IDREF // other allowed list if( builtinTypeSafeEnumCapableTypes.contains(localName) ) return true; } } type = type.getSimpleBaseType(); } while( type!=null ); return false; }
Example #12
Source File: AnyTypeBeanInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void serializeAttributes(Object element, XMLSerializer target) throws SAXException { NamedNodeMap al = ((Element)element).getAttributes(); int len = al.getLength(); for( int i=0; i<len; i++ ) { Attr a = (Attr)al.item(i); // work defensively String uri = a.getNamespaceURI(); if(uri==null) uri=""; String local = a.getLocalName(); String name = a.getName(); if(local==null) local = name; if (uri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE) && ("nil".equals(local))) { isNilIncluded = true; } if(name.startsWith("xmlns")) continue;// DOM reports ns decls as attributes target.attribute(uri,local,a.getValue()); } }
Example #13
Source File: MTOMDecorator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void startElement(TagName tagName) throws SAXException { if(tagName.local.equals("Include") && tagName.uri.equals(WellKnownNamespace.XOP)) { // found xop:Include String href = tagName.atts.getValue("href"); DataHandler attachment = au.getAttachmentAsDataHandler(href); if(attachment==null) { // report an error and ignore parent.getEventHandler().handleEvent(null); // TODO } base64data.set(attachment); next.text(base64data); inXopInclude = true; followXop = true; } else next.startElement(tagName); }
Example #14
Source File: AnyTypeBeanInfo.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void serializeAttributes(Object element, XMLSerializer target) throws SAXException { NamedNodeMap al = ((Element)element).getAttributes(); int len = al.getLength(); for( int i=0; i<len; i++ ) { Attr a = (Attr)al.item(i); // work defensively String uri = a.getNamespaceURI(); if(uri==null) uri=""; String local = a.getLocalName(); String name = a.getName(); if(local==null) local = name; if (uri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE) && ("nil".equals(local))) { isNilIncluded = true; } if(name.startsWith("xmlns")) continue;// DOM reports ns decls as attributes target.attribute(uri,local,a.getValue()); } }
Example #15
Source File: SimpleTypeBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns true if the given simple type can be mapped to a * type-safe enum class. * * <p> * JAXB spec places a restrictrion as to what type can be * mapped to a type-safe enum. This method enforces this * constraint. */ public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) { do { if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) { // type must be derived from one of these types String localName = type.getName(); if( localName!=null ) { if( localName.equals("anySimpleType") ) return false; // catch all case if( localName.equals("ID") || localName.equals("IDREF") ) return false; // not ID/IDREF // other allowed list if( builtinTypeSafeEnumCapableTypes.contains(localName) ) return true; } } type = type.getSimpleBaseType(); } while( type!=null ); return false; }
Example #16
Source File: XMLSchemaInternalizationLogic.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Creates a new XML Schema element of the given local name * and insert it as the first child of the given parent node. * * @return * Newly create element. */ private Element insertXMLSchemaElement( Element parent, String localName ) { // use the same prefix as the parent node to avoid modifying // the namespace binding. String qname = parent.getTagName(); int idx = qname.indexOf(':'); if(idx==-1) qname = localName; else qname = qname.substring(0,idx+1)+localName; Element child = parent.getOwnerDocument().createElementNS( WellKnownNamespace.XML_SCHEMA, qname ); NodeList children = parent.getChildNodes(); if( children.getLength()==0 ) parent.appendChild(child); else parent.insertBefore( child, children.item(0) ); return child; }
Example #17
Source File: SimpleTypeBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns true if the given simple type can be mapped to a * type-safe enum class. * * <p> * JAXB spec places a restrictrion as to what type can be * mapped to a type-safe enum. This method enforces this * constraint. */ public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) { do { if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) { // type must be derived from one of these types String localName = type.getName(); if( localName!=null ) { if( localName.equals("anySimpleType") ) return false; // catch all case if( localName.equals("ID") || localName.equals("IDREF") ) return false; // not ID/IDREF // other allowed list if( builtinTypeSafeEnumCapableTypes.contains(localName) ) return true; } } type = type.getSimpleBaseType(); } while( type!=null ); return false; }
Example #18
Source File: XsiNilLoader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
protected Loader selectLoader(UnmarshallingContext.State state, TagName ea) throws SAXException { int idx = ea.atts.getIndex(WellKnownNamespace.XML_SCHEMA_INSTANCE,"nil"); if (idx!=-1) { Boolean b = DatatypeConverterImpl._parseBoolean(ea.atts.getValue(idx)); if (b != null && b) { onNil(state); boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0; // see issues 6759703 and 565 - need to preserve attributes even if the element is nil; only when the type is stored in JAXBElement if (!(hasOtherAttributes && (state.getPrev().getTarget() instanceof JAXBElement))) { return Discarder.INSTANCE; } } } return defaultLoader; }
Example #19
Source File: IncorrectNamespaceURIChecker.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void startPrefixMapping(String prefix, String uri) throws SAXException { if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; //xml prefix shall not be declared based on jdk api javadoc if( prefix.equals("jaxb") ) isJAXBPrefixUsed = true; if( uri.equals(Const.JAXB_NSURI) ) isCustomizationUsed = true; super.startPrefixMapping(prefix, uri); }
Example #20
Source File: ArrayInfoUtil.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Computes the type name of the array from that of the item type. */ public static QName calcArrayTypeName(QName n) { String uri; if(n.getNamespaceURI().equals(WellKnownNamespace.XML_SCHEMA)) { TODO.checkSpec("this URI"); uri = "http://jaxb.dev.java.net/array"; } else uri = n.getNamespaceURI(); return new QName(uri,n.getLocalPart()+"Array"); }
Example #21
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public String print(Date v) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); GregorianCalendar cal = new GregorianCalendar(0,0,0); cal.setTime(v); if ((type != null) && (WellKnownNamespace.XML_SCHEMA.equals(type.getNamespaceURI())) && DATE.equals(type.getLocalPart())) { return DatatypeConverterImpl._printDate(cal); } else { return DatatypeConverterImpl._printDateTime(cal); } }
Example #22
Source File: ClassSelector.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public ClassSelector() { classBinder = new Abstractifier(new DefaultClassBinder()); Ring.add(ClassBinder.class,classBinder); classScopes.push(null); // so that the getClassFactory method returns null XSComplexType anyType = Ring.get(XSSchemaSet.class).getComplexType(WellKnownNamespace.XML_SCHEMA,"anyType"); bindMap.put(anyType,new Binding(anyType,CBuiltinLeafInfo.ANYTYPE)); }
Example #23
Source File: ForkingFilter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void startPrefixMapping(String prefix, String uri) throws SAXException { if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; //xml prefix shall not be declared based on jdk api javadoc if(side!=null) side.startPrefixMapping(prefix,uri); namespaces.add(prefix); namespaces.add(uri); super.startPrefixMapping(prefix,uri); }
Example #24
Source File: AbstractExtensionBindingChecker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void startPrefixMapping(String prefix, String uri) throws SAXException { if (WellKnownNamespace.XML_NAMESPACE_URI.equals(uri)) return; super.startPrefixMapping(prefix, uri); //xml prefix shall not be declared based on jdk api javado nsSupport.pushContext(); nsSupport.declarePrefix(prefix,uri); }
Example #25
Source File: XmlSchemaGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Writes a type attribute (if the referenced type is a global type) * or writes out the definition of the anonymous type in place (if the referenced * type is not a global type.) * * Also provides processing for ID/IDREF, MTOM @xmime, and swa:ref * * ComplexTypeHost and SimpleTypeHost don't share an api for creating * and attribute in a type-safe way, so we will compromise for now and * use _attribute(). */ private void writeTypeRef(TypeHost th, NonElementRef<T, C> typeRef, String refAttName) { // ID / IDREF handling switch(typeRef.getSource().id()) { case ID: th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "ID")); return; case IDREF: th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "IDREF")); return; case NONE: // no ID/IDREF, so continue on and generate the type break; default: throw new IllegalStateException(); } // MTOM handling MimeType mimeType = typeRef.getSource().getExpectedMimeType(); if( mimeType != null ) { th._attribute(new QName(WellKnownNamespace.XML_MIME_URI, "expectedContentTypes", "xmime"), mimeType.toString()); } // ref:swaRef handling if(generateSwaRefAdapter(typeRef)) { th._attribute(refAttName, new QName(WellKnownNamespace.SWA_URI, "swaRef", "ref")); return; } // type name override if(typeRef.getSource().getSchemaType()!=null) { th._attribute(refAttName,typeRef.getSource().getSchemaType()); return; } // normal type generation writeTypeRef(th, typeRef.getTarget(), refAttName); }
Example #26
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public String print(Date v) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); GregorianCalendar cal = new GregorianCalendar(0,0,0); cal.setTime(v); if ((type != null) && (WellKnownNamespace.XML_SCHEMA.equals(type.getNamespaceURI())) && DATE.equals(type.getLocalPart())) { return DatatypeConverterImpl._printDate(cal); } else { return DatatypeConverterImpl._printDateTime(cal); } }
Example #27
Source File: XMLSchemaInternalizationLogic.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected String findExternalResource( String nsURI, String localName, Attributes atts) { if( WellKnownNamespace.XML_SCHEMA.equals(nsURI) && ("import".equals(localName) || "include".equals(localName) ) ) return atts.getValue("schemaLocation"); else return null; }
Example #28
Source File: ClassSelector.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public ClassSelector() { classBinder = new Abstractifier(new DefaultClassBinder()); Ring.add(ClassBinder.class,classBinder); classScopes.push(null); // so that the getClassFactory method returns null XSComplexType anyType = Ring.get(XSSchemaSet.class).getComplexType(WellKnownNamespace.XML_SCHEMA,"anyType"); bindMap.put(anyType,new Binding(anyType,CBuiltinLeafInfo.ANYTYPE)); }
Example #29
Source File: XMLSchemaInternalizationLogic.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected String findExternalResource( String nsURI, String localName, Attributes atts) { if( WellKnownNamespace.XML_SCHEMA.equals(nsURI) && ("import".equals(localName) || "include".equals(localName) ) ) return atts.getValue("schemaLocation"); else return null; }
Example #30
Source File: XmlSchemaGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Writes a type attribute (if the referenced type is a global type) * or writes out the definition of the anonymous type in place (if the referenced * type is not a global type.) * * Also provides processing for ID/IDREF, MTOM @xmime, and swa:ref * * ComplexTypeHost and SimpleTypeHost don't share an api for creating * and attribute in a type-safe way, so we will compromise for now and * use _attribute(). */ private void writeTypeRef(TypeHost th, NonElementRef<T, C> typeRef, String refAttName) { // ID / IDREF handling switch(typeRef.getSource().id()) { case ID: th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "ID")); return; case IDREF: th._attribute(refAttName, new QName(WellKnownNamespace.XML_SCHEMA, "IDREF")); return; case NONE: // no ID/IDREF, so continue on and generate the type break; default: throw new IllegalStateException(); } // MTOM handling MimeType mimeType = typeRef.getSource().getExpectedMimeType(); if( mimeType != null ) { th._attribute(new QName(WellKnownNamespace.XML_MIME_URI, "expectedContentTypes", "xmime"), mimeType.toString()); } // ref:swaRef handling if(generateSwaRefAdapter(typeRef)) { th._attribute(refAttName, new QName(WellKnownNamespace.SWA_URI, "swaRef", "ref")); return; } // type name override if(typeRef.getSource().getSchemaType()!=null) { th._attribute(refAttName,typeRef.getSource().getSchemaType()); return; } // normal type generation writeTypeRef(th, typeRef.getTarget(), refAttName); }