Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c8feae

Browse files
New method getnamespace.
Since the application never gets to see the namespace abbreviation used in the XML document, but some applications may need to know them, we provide this method.
1 parent f730fc3 commit 1c8feae

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/lib/libxmllib.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ \section{\module{xmllib} ---
9292
return the translated string.
9393
\end{methoddesc}
9494

95+
\begin{methoddesc}{getnamespace}{}
96+
Return a mapping of namespace abbreviations to namespace URIs that are
97+
currently in effect.
98+
\end{methoddesc}
99+
95100
\begin{methoddesc}{handle_xml}{encoding, standalone}
96101
This method is called when the \samp{<?xml ...?>} tag is processed.
97102
The arguments are the values of the encoding and standalone attributes

Lib/xmllib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ def translate_references(self, data, all = 1):
222222
else:
223223
i = s + len(str)
224224

225+
# Interface - return a dictionary of all namespaces currently valid
226+
def getnamespace(self):
227+
nsdict = {}
228+
for t, d, nst in self.stack:
229+
nsdict.update(d)
230+
return nsdict
231+
225232
# Internal -- handle data as far as reasonable. May leave state
226233
# and data to be processed by a subsequent call. If 'end' is
227234
# true, force handling all data as if followed by EOF marker.

0 commit comments

Comments
 (0)