JUnit XML "packages" in hudson - junit

I'm generating XML's myself that look enough like JUnit for Hudson to read them. It works great except I can't figure out what the "packages" list is in the Hudson web GUI. How do I make an XML that will be interpreted by Hudson as a "package?"
<testsuites>
<testsuite>
<testcase classname="class\name\that\is\really\folders" name="test_name.log" time="231">
</testcase>
</testsuite>
</testsuites>
Hudson will list this as:
Package: (root)
Class: class\name\that\is\really\folders
Test Name: test_name.log

#pushy - I tried that before, but when I tried to prove you wrong I got it this time ;-).
<testsuites>
<testsuite name="package.name.of.your.testclass">
<testcase classname="package.name.of.your.testclass.class\name\that\is\really\folders" name="test_name.log" time="231">
</testcase>
</testsuite>
</testsuites>
You must prefix the classname of each test case with the testsuite name for it to be accepted as a "package".

No need for redundancy! Jenkins nicely infers the package and class names if you:
use the name attribute instead of classname
ensure the <testsuite> element's name attribute has at least two dot delimited "sections." Now all the enclosed <testcase> elements will get a package and class. The very last part will be the class name. The remainder will be be the package name.
Like this:
<testsuites>
<testsuite name="packagename.classname">
<testcase name="test_name.log" time="231"></testcase>
</testsuite>
</testsuites>

I think Jenkins takes the package name from the name attribute in the testsuite tag.
You could try changing your XML like this
<testsuites>
<testsuite name="package.name.of.your.testclass">
<testcase classname="class\name\that\is\really\folders" name="test_name.log" time="231">
</testcase>
</testsuite>
</testsuites>

Related

Custom Configuration in .NET - Use element instead of attributes

In all examples I've seen of custom configurations nobody seems to use elements to store data, e.g.
<data name="1">
<server>aServer</server>
<ip>anipaddress</ip>
</data>
Is this actually possible?
I know I can use attributes like this:
<data name="1" server="aServer" ip="anipaddress"/>
TIA
The default implementation of ConfigurationElement.DeserializeElement does not support nodes of type XmlNodeType.Text or XmlNodeType.CDATA and throws a ConfigurationErrorsException with the following error message: The configuration section cannot contain a CDATA or text element.
Thus, to store information using the element text content, override the ConfigurationElement.DeserializeElement method.
Yes you can do that.
<configuration>
<configSections>
<sectionGroup name="pageAppearanceGroup">
<section
name="pageAppearance"
type="Samples.AspNet.PageAppearanceSection"
allowLocation="true"
allowDefinition="Everywhere"/>
</sectionGroup>
</configSections>
<pageAppearanceGroup>
<pageAppearance remoteOnly="true">
<font name="TimesNewRoman" size="18"/>
<color background="000000" foreground="FFFFFF"/>
</pageAppearance>
</pageAppearanceGroup>
</configuration>
Then to access the variables
Samples.AspNet.PageAppearanceSection config = (Samples.AspNet.PageAppearanceSection)System.Configuration.ConfigurationManager.GetSection(
"pageAppearanceGroup/pageAppearance");
Response.Write("<h2>Settings in the PageAppearance Section:</h2>");
Response.Write(string.Format("RemoteOnly: {0}<br>",
config.RemoteOnly));
etc....
Check this link
http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

Dynamically select Nodes in Xpath in SQL Server 2008

I have following XML to parse in SQL Server 2008
<Root>
<Document>
<Body>
<Component>
</Component>
</Body>
</Document>
</Root>
I want to retrieve all the <Component> tags in my xml, the issue is that <Document> tag at times might not come, Hence my xpath query of (root/document/body) won't work. Is there way I can get all <Component> tags irrespective of presence of <Document> tag?
You could always use an XPath query of
//component
to get all <component> elements in your entire document - no matter where they are and what other tags there are around it

Problem adding namespaces to MSXML (using setProperty('SelectionNamespaces', ...))

A while back, I asked a question regarding the usage of namespaces in MSXML. At first, I circumvented the whole thing with the XPath *[local-name()]-hack (see my previous post), but having a crisis of conscience I decided to do things the right way. (Doh!)
Consider the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root xsi:schemaLocation="http://www.foo.bar mySchema.xsd" xmlns="http://www.foo.bar" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MyElement>
</MyElement>
</Root>
When I try to add these namespaces using IXMLDOMDocument3.setProperty('SelectionNamespaces', NSString);, I get the following error: "SelectionNamespaces property value is invalid. Only well-formed xmlns attributes are allowed.". When removing the namespace xsi:schemaLocation="http://www.foo.bar mySchema.xsd", everything runs smoothly. What am I doing wrong here? Is there an error in the XML? Is MSXML to blame?
xsi:schemaLocation="..." is not a namespace definition, it is an attribute of the <Root> element which is in xsi namespace.
So removing this from the list of namespaces as you did is already the solution.

what is the exact usage of xmlns in xml, and html

Does any one know what is the exact usage of xmlns in HTML, XML files?
Edit: Why do we need this namespace? What is its usage?
The xmlns attribute has special handling, that allows the declaration of a namespace.
All names, such as tag names, in a document belong to a namespace. In the absence of the xmlns attribute all the names belong to the "no name" namespace. Hence:-
<root><item /></root>
In the above example both root and item are names in the "no name" namespace. Whereas:-
<root xmlns="urn:mydomain.com:mystuff"><item /></root>
Now root and item exist in the "urn:mydomain.com:mystuff" namespace.
The xmlns can further define additional namespaces elements of which can be distinguished from others by using an alias prefix:-
<root xmlns="urn:mydomain.com:mystuff" xmlns:a="urn:otherdomain.com:other">
<item>
<a:supplement />
</item>
</root>
In this case root and item continue to be in the "urn:mydomain.com:mystuff" namespace but a:supplement indicates that the name supplement is in the "urn:otherdomain.com:other" namespace.
What does this acheive?
The X in XML stands for eXtensible. One goal is to allow additional information to layer onto an existing document, i.e., the ability to extend the document. Consider:-
Party A create a document:-
<root>
<item />
<root>
Party B extends the document by including additional information:-
<root>
<item />
<supplement />
</root>
Later Party A adds new info to their original form of the document and just so happen to also use the name supplement in their original. We could end up with something like:-
<root>
<item />
<supplement />
<supplement />
</root>
Which supplement element belongs to which party? By using namespaces the document would look like this:-
<root xmlns="urn:mydomain.com:mystuff" xmlns:a="urn:otherdomain.com:other">
<item />
<supplement />
<a:supplement />
</root>
Now when it comes to parsing and querying the XML its clear which element belongs to whom. Namespaces elimnate the collision between what would otherwise be a global set of simple names.
The xmlns attribute declares an XML Namespace. The Namespaces in XML standard discusses this element in depth.
Namespaces are used primarily to avoid conflicts between element names when mixing XML languages. If you have a particular application that you have questions about, perhaps you could post an example.
XML namespaces help contextualize elements an attributes, among other things. It also offers a precise identification for a particular element or attribute.
For instance, the <html> element can be defined by anyone and have any meaning. However, the <html> element within the http://www.w3.org/1999/xhtml namespace is unique and refers to the XHTML.
Namespaces also prove useful when dealing with homographs, when using multiple XML languages in a single file.
In HTML, xmlns is just a talisman to make moving from and to XHTML easier. It doesn't do anything at all.
Namespaces let you reduce ambiguity when there are duplicates. You could have a <title> tag that refers to authors and <title> tag that refers to a salutation, like Mr., Mrs. etc. To differentiate, you could assign them to different namespaces.
You can also use namespaces when validating documents for conformance to a particular standard/restrictions, where the namespace would indicate to what "Schema" that the document is belonging to.

How do you make an element in an XML Schema that allows any HTML element as its children?

I am trying to create an element in an XML schema such that only standard (X)HTML elements can be used as children. What I've tried is this:
<xs:element name="description">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any namespace="http://www.w3.org/1999/xhtml" />
</xs:sequence>
</xs:complexType>
</xs:element>
Of course, this doesn't work, as the following XML doesn't explicitly specify the namespace:
<description>
<p>this is a test</p>
<p>this is a <b>bold</b> test</p>
<h1>Those were the tests</h1>
</description>
Do I need to specify the namespace somewhere in the document, or can I get it in the schema?
I think you need to disable the content processing thus:
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip"/>
See section 5.5 in the XML Schema spec (particularly the examples)
Your schema looks ok. Note that the default value for xs:any/#processContents is strict, which means your XHTML elements will be also validated so you will need to have also an XHTML schema and import it from your schema. You can use processContents="lax" inside xs:any to specify that the validation will be applied only if there is a schema for those elements.
Your problem is in the instance where you should specify the namespace for the XHTML element. You can declare the XHTML namespace as default namespace on each element, for example
<p xmlns="http://www.w3.org/1999/xhtml">this is a test</p>
or you can declare it bound to a prefix, h for instance and then use that prefix to qualify your XHTML elements:
<description xmlns:h="http://www.w3.org/1999/xhtml">
<h:p>this is a test</h:p>
<h:p>this is a <b>bold</b> test</h:p>
<h:h1>Those were the tests</h:h1>
</description>
DTDs are not namespace aware and there namepsace declarations are just attributes, thus it is possible to declare a fixed xmlns attribute on an element to put it in a specific namespace automatically. XML Schemas are namespace aware and you cannot have a namespace declaration as a fixed attribute.
I think you really need to view this page