code: public static String prepareExtendedIdentifier(Document doc) throws MarshalException {
  
  		Transformer tf = null;
  		String res = null;
  
  		try {
  			tf = TRANSFORMER_FACTORY.newTransformer();
  		} catch (TransformerConfigurationException e) {
  			IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]");
  			throw new MarshalException(e.getMessage());
  		}
  
  		fixupNamespace(doc);
  
  		ByteArrayOutputStream baos = new ByteArrayOutputStream();
  		DOMSource domSource = new DOMSource(doc.getFirstChild());
  		Result result = new StreamResult(baos);
  
  		tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
  		tf.setOutputProperty(OutputKeys.INDENT, "no");
  		tf.setOutputProperty(OutputKeys.METHOD, "xml");
  
  		try {
  			tf.transform(domSource, result);
  		} catch (TransformerException e) {
  			IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]");
  			throw new MarshalException(e.getMessage());
  		}
  
  		ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  		InputSource inputSource = new InputSource(bais);
  
  		CanonicalXML cxml = new CanonicalXML();
  		XMLReader reader = null;
  		try {
  			reader = XMLReaderFactory.createXMLReader();
  		} catch (SAXException e) {
  			IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]");
  			throw new MarshalException(e.getMessage());
  		}
  
  		try {
  			res = cxml.toCanonicalXml2(reader, inputSource, true);
  		} catch (Exception e) {
  			// hmm... toCanonicalXML throws Exception...
  			IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]");
  			throw new MarshalException(e.getMessage());
  		}
  
  		return escapeXml(res);
  	}
docs: Prepare an extended identifier for publish by removing
  namespace added by XSL transformation and encoding all
  relevant XML entities.
  
  @since 0.1.5
  @param str
  @return namespace ns0 stripped and encoded XML string
  @throws MarshalException