XPath query to get nth instance of an element

This is a FAQ: //somexpression[$N] means “Find every node selected by //somexpression that is the $Nth child of its parent”. What you want is: (//input[@id=”search_query”])[2] Remember: The [] operator has higher precedence (priority) than the // abbreviation.

Auto line-wrapping in SVG text

Text wrapping is not part of SVG1.1, the currently implemented spec. In case you are going to use your SVG graphic on the Web, you can embed HTML inside SVG via the <foreignObject/> element. Example: <svg …> <switch> <foreignObject x=”20″ y=”90″ width=”150″ height=”200″> <p xmlns=”http://www.w3.org/1999/xhtml”>Text goes here</p> </foreignObject> <text x=”20″ y=”20″>Your SVG viewer cannot display … Read more

What’s the difference between xsd:include and xsd:import?

The fundamental difference between include and import is that you must use import to refer to declarations or definitions that are in a different target namespace and you must use include to refer to declarations or definitions that are (or will be) in the same target namespace. Source: https://web.archive.org/web/20070804031046/http://xsd.stylusstudio.com/2002Jun/post08016.htm

Using a custom typeface in Android

Yes It is possible. You have to create a custom view which extends text view. In attrs.xml in values folder: <resources> <declare-styleable name=”MyTextView”> <attr name=”first_name” format=”string”/> <attr name=”last_name” format=”string”/> <attr name=”ttf_name” format=”string”/> </declare-styleable> </resources> In main.xml: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:lht=”http://schemas.android.com/apk/res/com.lht” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Hello”/> <com.lht.ui.MyTextView android:id=”@+id/MyTextView” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Hello friends” lht:ttf_name=”ITCBLKAD.TTF” /> … Read more

How to parse XML to R data frame

Data in XML format are rarely organized in a way that would allow the xmlToDataFrame function to work. You’re better off extracting everything in lists and then binding the lists together in a data frame: require(XML) data <- xmlParse(“http://forecast.weather.gov/MapClick.php?lat=29.803&lon=-82.411&FcstType=digitalDWML”) xml_data <- xmlToList(data) In the case of your example data, getting location and start time is … Read more

How to make type depend on attribute value using Conditional Type Assignment

You can do this using XSD 1.1’s Conditional Type Assignment: <?xml version=”1.0″ encoding=”UTF-8″?> <xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema” xmlns:vc=”http://www.w3.org/2007/XMLSchema-versioning” elementFormDefault=”qualified” vc:minVersion=”1.1″> <xs:element name=”listOfA”> <xs:complexType> <xs:sequence> <xs:element name=”a” maxOccurs=”unbounded”> <xs:alternative test=”@type = 1″ type=”a1Type”/> <xs:alternative test=”@type = 2″ type=”a2Type”/> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name=”a1Type”> <xs:sequence> <xs:element name=”name”/> <xs:element name=”surname”/> </xs:sequence> </xs:complexType> <xs:complexType name=”a2Type”> <xs:sequence> <xs:element name=”name”/> <xs:element name=”id”/> … Read more

How to fix error: The markup in the document following the root element must be well-formed

General case The markup in the document following the root element must be well-formed. This error indicates that your XML has markup following the root element. In order to be well-formed, XML must have exactly one root element, and there can be no further markup following the single root element. One root element example (GOOD) … Read more