public void run() { Set<String> declaredPrefixes = new HashSet<String>(); for( Node n=node; n!=null && n.getNodeType()==Node.ELEMENT_NODE; n=n.getParentNode() ) { NamedNodeMap atts = n.getAttributes(); if(atts==null) continue; // broken DOM. but be graceful. for( int i=0; i<atts.getLength(); i++ ) { Attr a = (Attr)atts.item(i); String nsUri = a.getNamespaceURI(); if(nsUri==null || !nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) continue; // not a namespace declaration String prefix = a.getLocalName(); if(prefix==null) continue; // broken DOM. skip to be safe if(prefix.equals("xmlns")) { prefix = ""; } String value = a.getValue(); if(value==null) continue; // broken DOM. skip to be safe if(declaredPrefixes.add(prefix)) { serializer.addInscopeBinding(value,prefix); } } } } }
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } } }
private void prewrite(XmlOutput out, boolean fragment, Runnable postInitAction) throws IOException, SAXException, XMLStreamException { serializer.startDocument(out,fragment,getSchemaLocation(),getNoNSSchemaLocation()); if(postInitAction!=null) postInitAction.run(); if(prefixMapper!=null) { // be defensive as we work with the user's code String[] decls = prefixMapper.getContextualNamespaceDecls(); if(decls!=null) { // defensive check for( int i=0; i<decls.length; i+=2 ) { String prefix = decls[i]; String nsUri = decls[i+1]; if(nsUri!=null && prefix!=null) // defensive check serializer.addInscopeBinding(nsUri,prefix); } } } serializer.setPrefixMapper(prefixMapper); }
public void run() { Set<String> declaredPrefixes = new HashSet<String>(); for( Node n=node; n!=null && n.getNodeType()==Node.ELEMENT_NODE; n=n.getParentNode() ) { NamedNodeMap atts = n.getAttributes(); if(atts==null) continue; // broken DOM. but be graceful. for( int i=0; i<atts.getLength(); i++ ) { Attr a = (Attr)atts.item(i); String nsUri = a.getNamespaceURI(); if(nsUri==null || !nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) continue; // not a namespace declaration String prefix = a.getLocalName(); if(prefix==null) continue; // broken DOM. skip to be safe if(prefix.equals("xmlns")) { prefix = ""; } String value = a.getValue(); if(value==null) continue; // broken DOM. skip to be safe if(declaredPrefixes.add(prefix)) { serializer.addInscopeBinding(value,prefix); } } } } }
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } } }
private void prewrite(XmlOutput out, boolean fragment, Runnable postInitAction) throws IOException, SAXException, XMLStreamException { serializer.startDocument(out,fragment,getSchemaLocation(),getNoNSSchemaLocation()); if(postInitAction!=null) postInitAction.run(); if(prefixMapper!=null) { // be defensive as we work with the user's code String[] decls = prefixMapper.getContextualNamespaceDecls(); if(decls!=null) { // defensive check for( int i=0; i<decls.length; i+=2 ) { String prefix = decls[i]; String nsUri = decls[i+1]; if(nsUri!=null && prefix!=null) // defensive check serializer.addInscopeBinding(nsUri,prefix); } } } serializer.setPrefixMapper(prefixMapper); }
public void run() { Set<String> declaredPrefixes = new HashSet<String>(); for( Node n=node; n!=null && n.getNodeType()==Node.ELEMENT_NODE; n=n.getParentNode() ) { NamedNodeMap atts = n.getAttributes(); if(atts==null) continue; // broken DOM. but be graceful. for( int i=0; i<atts.getLength(); i++ ) { Attr a = (Attr)atts.item(i); String nsUri = a.getNamespaceURI(); if(nsUri==null || !nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) continue; // not a namespace declaration String prefix = a.getLocalName(); if(prefix==null) continue; // broken DOM. skip to be safe if(prefix.equals("xmlns")) { prefix = ""; } String value = a.getValue(); if(value==null) continue; // broken DOM. skip to be safe if(declaredPrefixes.add(prefix)) { serializer.addInscopeBinding(value,prefix); } } } } }
public void run() { Set<String> declaredPrefixes = new HashSet<String>(); for( Node n=node; n!=null && n.getNodeType()==Node.ELEMENT_NODE; n=n.getParentNode() ) { NamedNodeMap atts = n.getAttributes(); if(atts==null) continue; // broken DOM. but be graceful. for( int i=0; i<atts.getLength(); i++ ) { Attr a = (Attr)atts.item(i); String nsUri = a.getNamespaceURI(); if(nsUri==null || !nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) continue; // not a namespace declaration String prefix = a.getLocalName(); if(prefix==null) continue; // broken DOM. skip to be safe if(prefix.equals("xmlns")) { prefix = ""; } String value = a.getValue(); if(value==null) continue; // broken DOM. skip to be safe if(declaredPrefixes.add(prefix)) { serializer.addInscopeBinding(value,prefix); } } } } }
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } } }
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } } }
private void prewrite(XmlOutput out, boolean fragment, Runnable postInitAction) throws IOException, SAXException, XMLStreamException { serializer.startDocument(out,fragment,getSchemaLocation(),getNoNSSchemaLocation()); if(postInitAction!=null) postInitAction.run(); if(prefixMapper!=null) { // be defensive as we work with the user's code String[] decls = prefixMapper.getContextualNamespaceDecls(); if(decls!=null) { // defensive check for( int i=0; i<decls.length; i+=2 ) { String prefix = decls[i]; String nsUri = decls[i+1]; if(nsUri!=null && prefix!=null) // defensive check serializer.addInscopeBinding(nsUri,prefix); } } } serializer.setPrefixMapper(prefixMapper); }
private void prewrite(XmlOutput out, boolean fragment, Runnable postInitAction) throws IOException, SAXException, XMLStreamException { serializer.startDocument(out,fragment,getSchemaLocation(),getNoNSSchemaLocation()); if(postInitAction!=null) postInitAction.run(); if(prefixMapper!=null) { // be defensive as we work with the user's code String[] decls = prefixMapper.getContextualNamespaceDecls(); if(decls!=null) { // defensive check for( int i=0; i<decls.length; i+=2 ) { String prefix = decls[i]; String nsUri = decls[i+1]; if(nsUri!=null && prefix!=null) // defensive check serializer.addInscopeBinding(nsUri,prefix); } } } serializer.setPrefixMapper(prefixMapper); }