private static void convertNamespaces(XMLStreamReader streamReader, Element element) { for (int i = 0; i < streamReader.getNamespaceCount(); i++) { String uri = streamReader.getNamespaceURI(i); String prefix = streamReader.getNamespacePrefix(i); element.addNamespaceDeclaration(prefix, uri); } }
private static void convertNamespaces(XMLStreamReader streamReader, Element element) { for (int i = 0; i < streamReader.getNamespaceCount(); i++) { String uri = streamReader.getNamespaceURI(i); String prefix = streamReader.getNamespacePrefix(i); element.addNamespaceDeclaration(prefix, uri); } }
private static void convertNamespaces(XMLStreamReader streamReader, Element element) { for (int i = 0; i < streamReader.getNamespaceCount(); i++) { String uri = streamReader.getNamespaceURI(i); String prefix = streamReader.getNamespacePrefix(i); element.addNamespaceDeclaration(prefix, uri); } }
private static void convertNamespaces(XMLStreamReader streamReader, Element element) { for (int i = 0; i < streamReader.getNamespaceCount(); i++) { String uri = streamReader.getNamespaceURI(i); String prefix = streamReader.getNamespacePrefix(i); element.addNamespaceDeclaration(prefix, uri); } }
/** override addNamespaceDeclaration(prefix, uri) to make it immutable. * if namespacePrefix is not set, set it, else returns no-op * without message. * @param prefix * @param uri */ public void addNamespaceDeclaration(String prefix, String uri) { String namespaceURI = this.getNamespaceURI(prefix); if (namespaceURI == null) { super.addNamespaceDeclaration(prefix, uri); } }
/** * Marshal the data stored in this object into Element objects. * * @return An element that holds the data associated with this object. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_ATOM); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); this.marshallElements(entry); return entry; }
/** * Marshal the data stored in this object into Element objects. * * @return An element that holds the data associated with this object. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_ATOM); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); this.marshallElements(entry); return entry; }
/** * Mashall the data stored in this object into Element objects. * * @return An element that holds the data associated with this object. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_ATOM); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); this.marshallElements(entry); return entry; }
private void readNamespaceDeclaration(ArrayByteList src, Element dst, int type) { String prefix = readString(src, 4, type); String uri = readName(src, 6, type); if (dst != null) dst.addNamespaceDeclaration(prefix, uri); }
private void readNamespaceDeclaration(ArrayByteList src, Element dst, int type) { String prefix = readString(src, 4, type); String uri = readName(src, 6, type); if (dst != null) dst.addNamespaceDeclaration(prefix, uri); }
/** * creates a prefixed CMLX attribute (cmlx:foo="bar") on element in CMLX namespace * @param element * @param attName UNPREFIXED * @param attValue */ public static void addCMLXAttribute(Element element, String attName, String attValue) { Attribute attribute = makeCMLXAttribute(attName, attValue); element.addAttribute(attribute); element.addNamespaceDeclaration(CMLConstants.CMLX_PREFIX, CMLX_NS); }
/** * Overrides the marshal method in the parent SWORDEntry. This will * call the parent marshal method and then add the additional * elements that have been added in this subclass. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); Attribute error = new Attribute("href", errorURI); entry.addAttribute(error); super.marshallElements(entry); return entry; }
template.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); templates.put(Nodes.class.getName(), template);
template.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); templates.put(Nodes.class.getName(), template);
/** * Overrides the marshal method in the parent SWORDEntry. This will * call the parent marshal method and then add the additional * elements that have been added in this subclass. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); Attribute error = new Attribute("href", errorURI); entry.addAttribute(error); super.marshallElements(entry); return entry; }
/** * Overrides the marshall method in the parent SWORDEntry. This will * call the parent marshall method and then add the additional * elements that have been added in this subclass. */ public Element marshall() { Element entry = new Element(getQualifiedName(), Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); entry.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); Attribute error = new Attribute("href", errorURI); entry.addAttribute(error); super.marshallElements(entry); return entry; }
/** * Convenience method to wrap a plain string in an XHTML P element. * * @param text * to wrap */ public void addPlainText(String text) { Element p = new Element("xhtml:p", CMLConstants.XHTML_NS); p.addNamespaceDeclaration("xhtml", CMLConstants.XHTML_NS); p.appendChild(text); this.appendChild(p); }
/** * Marshal the data in this object to an Element object. * * @return A XOM Element that holds the data for this Content element. */ public final Element marshall() { Element service = new Element(getQualifiedName(), Namespaces.NS_APP); service.addNamespaceDeclaration(Namespaces.PREFIX_ATOM, Namespaces.NS_ATOM); service.addNamespaceDeclaration(Namespaces.PREFIX_DC_TERMS, Namespaces.NS_DC_TERMS); service.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD); if (swordVersion != null) { service.appendChild(swordVersion.marshall()); } if (swordVerbose != null) { service.appendChild(swordVerbose.marshall()); } if (swordNoOp != null) { service.appendChild(swordNoOp.marshall()); } if (swordMaxUploadSize != null) { service.appendChild(swordMaxUploadSize.marshall()); } if (generator != null) { service.appendChild(generator.marshall()); } for (Workspace item : workspaces) { service.appendChild(item.marshall()); } return service; }
/** * Write the specification to an output stream. * * @param specification * the specification * @param out * the output stream */ public void write(Specification specification, OutputStream out) { nu.xom.Element eSpec = toElement(specification); eSpec.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); eSpec.addAttribute(new nu.xom.Attribute("xsi:schemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "http://opendse.sourceforge.net http://opendse.sourceforge.net/schema.xsd")); nu.xom.Document doc = new nu.xom.Document(eSpec); try { Serializer serializer = new Serializer(out); serializer.setIndent(2); serializer.setMaxLength(2000); serializer.write(doc); serializer.flush(); } catch (IOException ex) { System.out.println(ex + " " + out); } }
public void generateXmlSchema(OutputStream output, boolean excludeOptional) throws Exception { Element configEl = new Element("config", namespaceUri); configEl.addNamespaceDeclaration(null, namespaceUri); for (InjectableProperty property : new ConfigClassAnalyzer(configClass).getConfigProperties()) { if (excludeOptional && property.isOptional()) { continue; } if (property.isContextual()) { continue; } if (property.isArray()) { addArrayProperty(configEl, property); } else if (property.isCollection()) { addCollectionProperty(configEl, property); } else if (property.isMap()) { addMapProperty(configEl, property); } else if (property.isReference()) { addReferenceProperty(configEl, property); } else { addScalarProperty(configEl, property); } } Serializer serializer = new Serializer(output, "utf-8"); serializer.setIndent(4); serializer.setMaxLength(160); serializer.write(new Document(configEl)); }