Changes for namespace triplets.
diff --git a/expat/doc/reference.html b/expat/doc/reference.html
index 59e4390..d848ab1 100644
--- a/expat/doc/reference.html
+++ b/expat/doc/reference.html
@@ -389,8 +389,8 @@
 <code>XML_SetNamespaceDeclHandler</code></a>.
 
 <p>Element type and attribute names that belong to a given namespace are
-passed to the appropriate handler in expanded form. This expanded form
-is a concatenation of the namespace URI, the separator character (which
+passed to the appropriate handler in expanded form. By default this expanded
+form is a concatenation of the namespace URI, the separator character (which
 is the 2nd argument to <code>XML_ParserCreateNS</code>), and the local
 name (i.e. the part after the colon). Names with undeclared prefixes are
 passed through to the handlers unchanged, with the prefix and colon still
@@ -398,6 +398,12 @@
 element names are only expanded when they are in the scope of a default
 namespace.
 
+<p>However if <a href="XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a>
+has been called with a non-zero <code>do_nst</code> parameter, then the
+expanded form for names with an explicit prefix is a concatenation of:
+URI, separator, local name, separator, prefix.
+</p>
+
 <p>You can set handlers for the start of a namespace declaration and for
 the end of a scope of a declaration with the
 <code>XML_SetNamespaceDeclHandler</code> function.
@@ -1435,5 +1441,25 @@
 </ul>
 </div>
 
+<div class="fcndec"><a name="XML_SetReturnNSTriplet"><pre>
+void
+XML_SetReturnNSTriplet(XML_Parser parser,
+                       int        do_nst);
+</pre></a></div>
+<div class="fcndef">
+<p>
+This function only has an effect when using a parser created with
+<a href="#XML_ParserCreateNS">XML_ParserCreateNS</a>, i.e. when namespace
+processing is in effect. The <code>do_nst</code> sets whether or not prefixes
+are returned with names qualified with a namespace prefix. If this function
+is called with <code>do_nst</code> non-zero, then afterwards namespace
+qualified names (that is qualified with a prefix as opposed to belonging
+to a default namespace) are returned as a triplet with the three parts
+separated by the namespace separator specified when the parser was created.
+The order of returned parts is URI, local name, and prefix.</p>
+<p>If <code>do_nst</code> is zero, then namespaces are reported in the
+default manner, URI then local_name separated by the namespace separator.</p>
+</div>
+
 </body>
 </html>
diff --git a/expat/lib/expat.h b/expat/lib/expat.h
index 612c6a7..49be3ee 100644
--- a/expat/lib/expat.h
+++ b/expat/lib/expat.h
@@ -167,6 +167,7 @@
 typedef void (*XML_EndElementHandler)(void *userData,
 				      const XML_Char *name);
 
+
 /* s is not 0 terminated. */
 typedef void (*XML_CharacterDataHandler)(void *userData,
 					 const XML_Char *s,
@@ -389,10 +390,10 @@
 		      XML_EndElementHandler end);
 
 void 
-XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler);
+XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
 
 void 
-XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler);
+XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
 
 void 
 XML_SetCharacterDataHandler(XML_Parser parser,
@@ -490,6 +491,20 @@
 markup to be passed to the default handler. */
 void  XML_DefaultCurrent(XML_Parser parser);
 
+/* If do_nst is non-zero, and namespace processing is in effect, and
+   a name has a prefix (i.e. an explicit namespace qualifier) then
+   that name is returned as a triplet in a single
+   string separated by the separator character specified when the parser
+   was created: URI + sep + local_name + sep + prefix.
+
+   If do_nst is zero, then namespace information is returned in the
+   default manner (URI + sep + local_name) whether or not the names
+   has a prefix.
+*/
+
+void
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
+
 /* This value is passed as the userData argument to callbacks. */
 void 
 XML_SetUserData(XML_Parser parser, void *userData);
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
index 340d045..55f2e51 100644
--- a/expat/lib/xmlparse.c
+++ b/expat/lib/xmlparse.c
@@ -362,6 +362,7 @@
   const ENCODING *m_internalEncoding;
   const XML_Char *m_protocolEncodingName;
   int m_ns;
+  int m_ns_triplets;
   void *m_unknownEncodingMem;
   void *m_unknownEncodingData;
   void *m_unknownEncodingHandlerData;
@@ -447,6 +448,7 @@
 #define unknownEncodingRelease (((Parser *)parser)->m_unknownEncodingRelease)
 #define protocolEncodingName (((Parser *)parser)->m_protocolEncodingName)
 #define ns (((Parser *)parser)->m_ns)
+#define ns_triplets (((Parser *)parser)->m_ns_triplets)
 #define prologState (((Parser *)parser)->m_prologState)
 #define processor (((Parser *)parser)->m_processor)
 #define errorCode (((Parser *)parser)->m_errorCode)
@@ -627,6 +629,7 @@
   paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
 #endif
   ns = 0;
+  ns_triplets = 0;
   poolInit(&tempPool, &(((Parser *) parser)->m_mem));
   poolInit(&temp2Pool, &(((Parser *) parser)->m_mem));
   protocolEncodingName = encodingName ? poolCopyString(&tempPool, encodingName) : 0;
@@ -695,6 +698,7 @@
   XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler;
   XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler;
   ELEMENT_TYPE * oldDeclElementType = declElementType;
+
   void *oldUserData = userData;
   void *oldHandlerArg = handlerArg;
   int oldDefaultExpandInternalEntities = defaultExpandInternalEntities;
@@ -702,6 +706,7 @@
 #ifdef XML_DTD
   int oldParamEntityParsing = paramEntityParsing;
 #endif
+  int oldns_triplets = ns_triplets;
 
   if (ns) {
     XML_Char tmp[2];
@@ -746,6 +751,7 @@
   if (oldExternalEntityRefHandlerArg != oldParser)
     externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
   defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
+  ns_triplets = oldns_triplets;
 #ifdef XML_DTD
   paramEntityParsing = oldParamEntityParsing;
   if (context) {
@@ -827,6 +833,11 @@
   handlerArg = parser;
 }
 
+void
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
+  ns_triplets = do_nst;
+}
+
 void XML_SetUserData(XML_Parser parser, void *p)
 {
   if (handlerArg == userData)
@@ -1985,6 +1996,15 @@
 	    if (!poolAppendChar(&tempPool, *s))
 	      return XML_ERROR_NO_MEMORY;
 	  } while (*s++);
+	  if (ns_triplets) {
+	    tempPool.ptr[-1] = namespaceSeparator;
+	    s = b->prefix->name;
+	    do {
+	      if (!poolAppendChar(&tempPool, *s))
+		return XML_ERROR_NO_MEMORY;
+	    } while (*s++);
+	  }
+
 	  appAtts[i] = poolStart(&tempPool);
 	  poolFinish(&tempPool);
 	}