Parse a fragment of a document, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. 'file' may be either a file name or an open file object.
(file, context, namespaces=True)
| 923 | |
| 924 | |
| 925 | def parseFragment(file, context, namespaces=True): |
| 926 | """Parse a fragment of a document, given the context from which it |
| 927 | was originally extracted. context should be the parent of the |
| 928 | node(s) which are in the fragment. |
| 929 | |
| 930 | 'file' may be either a file name or an open file object. |
| 931 | """ |
| 932 | if namespaces: |
| 933 | builder = FragmentBuilderNS(context) |
| 934 | else: |
| 935 | builder = FragmentBuilder(context) |
| 936 | |
| 937 | if isinstance(file, str): |
| 938 | with open(file, 'rb') as fp: |
| 939 | result = builder.parseFile(fp) |
| 940 | else: |
| 941 | result = builder.parseFile(file) |
| 942 | return result |
| 943 | |
| 944 | |
| 945 | def parseFragmentString(string, context, namespaces=True): |
nothing calls this directly
no test coverage detected
searching dependent graphs…