namespaces

Python: how to control namespace after an unhandled exception?

偶尔善良 提交于 2019-12-24 10:04:07
问题 Is there any way to control which namespace you end up in after an unhandled exception? For example, if I'm at an ipython prompt and I go run blah.py on a file with these contents: def spam(): ham = 'ham' crash = 1/0 eggs = 'eggs' if __name__ == '__main__': foo = 'foo' spam() it crashes out obviously but returns me to an ipython prompt, with foo now in the namespace (and any previously existing foo is now overwritten with 'foo' ). But no ham . For some post mortem inspection, it is often the

How to replace node values in XML with Python

纵然是瞬间 提交于 2019-12-24 09:00:09
问题 I am new to Python. Now I have to replace a number of values in an XML file with Python. The example snippet of XML is: <gmd:extent> <gmd:EX_Extent> <gmd:description gco:nilReason="missing"> <gco:CharacterString /> </gmd:description> <gmd:geographicElement> <gmd:EX_GeographicBoundingBox> <gmd:westBoundLongitude> <gco:Decimal>112.907</gco:Decimal> </gmd:westBoundLongitude> <gmd:eastBoundLongitude> <gco:Decimal>158.96</gco:Decimal> </gmd:eastBoundLongitude> <gmd:southBoundLatitude> <gco:Decimal

Problems in selecting a node in XML with Namespace using XPATH

你说的曾经没有我的故事 提交于 2019-12-24 08:27:15
问题 I have the following XPATH line: //det[@nItem="1"]/prod/cProd That successfully selects the desired node using XPath Visualizer, where it identifies automatically the namespace, and you define in which namespace you want to select. When I specify the namespace in C# with the following XPATH code: "http://www.portalfiscal.inf.br/nfe//det[@nItem=\"1\"]/prod/cProd" it gives me an XPathException: An unhandled exception of type 'System.Xml.XPath.XPathException' occurred in System.Xml.dll

Namespace Specification In Absence of Ambuguity

泪湿孤枕 提交于 2019-12-24 07:10:11
问题 Why do some languages, like C++ and Python, require the namespace of an object be specified even when no ambiguity exists? I understand that there are backdoors to this, like using namespace x in C++, or from x import * in Python. However, I can't understand the rationale behind not wanting the language to just "do the right thing" when only one accessible namespace contains a given identifier and no ambiguity exists. To me it's just unnecessary verbosity and a violation of DRY, since you're

Error loading xml in php (not absolute)

不问归期 提交于 2019-12-24 06:48:17
问题 I am trying tom load an XML document with multiple namespace declarations My php is: <?php $doc = new DOMDocument('1.0','UTF-8'); $doc->load( 'UBLCatalog.xml' ); $Items = $doc->getElementsByTagNameNS( "UBLCommonAggregateComponents","Item" ); foreach( $Items as $Item ) { $descriptions = $Item->getElementsByTagNameNS( "UBLCommonBasicComponents","Description" ); $description = $descriptions->item(0)->nodeValue; echo "<b>$description\n</b><br>"; } ?> The error is: xmlns: URI UBLCatalogDocument is

CLSCompliant(true) drags in unused references

时间秒杀一切 提交于 2019-12-24 05:43:11
问题 Can anyone explain the following behavior? In summary, if you create multiple CLS compliant libraries in Visual Studio 2008 and have them share a common namespace root, a library referencing another library will require references to that library's references even though it doesn't consume them. It's pretty difficult to explain in a single sentence, but here are steps to reproduce the behavior (pay close attention to the namespaces): Create a library called LibraryA and add a a single class

Why web.xml does not work when I do not use a global namespace?

浪尽此生 提交于 2019-12-24 05:15:46
问题 I have this very simple web.xml file: <?xml version="1.0" encoding="UTF-8" ?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <welcome-file-list> <welcome-file>testx.jsp</welcome-file> </welcome-file-list> </web-app> When I deploy the application and visit the context root, I will be taken to testx.jsp which is fine

C++ how to handle tr1 and non-tr1 namespaces in portable code?

允我心安 提交于 2019-12-24 05:04:05
问题 Is there a canonical way to deal with the namespace issues that arise when trying to maintain portable code between a TR1 and non-TR1 toolchain? I have a VC++2010 project that #include <type_traits> . I also have an LLVM 3.0 compiler that can handle this fine. This allows me to use templates such as: std::enable_if<typename> std::is_enum<typename> However I also need to build and maintain this code on an Xcode 4.5 clang compiler: $ /Applications/Xcode.app/Contents/Developer/Toolchains

Compiling C++ code on Mac

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 04:32:10
问题 I want to write very simple C++ programs on my Mac but I get errors. I don't have a lot of experience with C++ (and gcc) and the simple guides on the web also don't discuss this topic. Please have a look at my simple hello world program: erik2:~[03:38 pm]$ cat hw.cpp #include <iostream> int main () { cout<<"Hello World!"; return 0; } erik2:~[03:38 pm]$ gcc hw.cpp hw.cpp: In function ‘int main()’: hw.cpp:5: error: ‘cout’ was not declared in this scope Responding to the answers until now

Compiling C++ code on Mac

ε祈祈猫儿з 提交于 2019-12-24 04:32:09
问题 I want to write very simple C++ programs on my Mac but I get errors. I don't have a lot of experience with C++ (and gcc) and the simple guides on the web also don't discuss this topic. Please have a look at my simple hello world program: erik2:~[03:38 pm]$ cat hw.cpp #include <iostream> int main () { cout<<"Hello World!"; return 0; } erik2:~[03:38 pm]$ gcc hw.cpp hw.cpp: In function ‘int main()’: hw.cpp:5: error: ‘cout’ was not declared in this scope Responding to the answers until now