xml-namespaces

Unqualified XSD global attribute references

做~自己de王妃 提交于 2019-12-17 20:50:03
问题 The following XML schema fails to validate with following XML instance document. Is there any way to rewrite the schema so the instance document validates, within the given constraints? Constraints The attribute cannot be local to the element The instance document must be unchanged (Invalid) Schema <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3

Adding namespaces to root element of xml using jaxb

此生再无相见时 提交于 2019-12-17 20:15:31
问题 I am creating an xml file whose root elemenet structure shuould be like: <RootElement xmlns="http://www.mysite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mysite.com/abc.xsd"> i created package-info.java class but i can get only one namespace by writing this code: @XmlSchema( namespace = "http://www.mysite.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package myproject.myapp; import javax.xml.bind.annotation.XmlSchema;

Can I use predefined namespaces when loading an XDocument?

一个人想着一个人 提交于 2019-12-17 19:47:07
问题 I often have to deal with XML documents that contain namespaced elements, but doesn't declare the namespace. For example: <root> <a:element/> </root> Because the prefix "a" is never assigned a namespace URI, the document is invalid. When I load such an XML document using the following code: using (StreamReader reader = new StreamReader(new FileStream(inputFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { doc = XDocument.Load(reader, LoadOptions.PreserveWhitespace); } it

Weirdness with XDocument, XPath and namespaces

余生长醉 提交于 2019-12-17 18:38:36
问题 I have an XML document that looks like this: <kmsg xmlns="http://url1" xmlns:env="url1" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="http://location that does not exist.xsd"> <header> <env:envelope> <env:source branch="907" machine="0" password="J123"/> </env:envelope> </header> <body> <OrderResponse xmlns="urn:schemasbasdaorg:2000:orderResponse:xdr:3.01"> <SomeMoreNodes/> </OrderResponse> </body> It does not have any schemas available despite having namespaces

SimpleXmlElement and XPath, getting empty array()

巧了我就是萌 提交于 2019-12-17 16:28:14
问题 I am having a little trouble with parsing XML from a google checkout response. The XML is coming straight from the google server so there is no problem with the XML itself. I want to get hold of all the new-order-notification tags I tried this but get an empty array() returned everytime. $xml = new SimpleXmlElement($raw_xml); $notifications = $xml->xpath('notifications'); $notifications = $xml->xpath('/notification-history-response/notifications/new-order-notification'); $notifications = $xml

XML element has namespace, my XPATH does not work

主宰稳场 提交于 2019-12-17 15:58:19
问题 I was given the following XML: <root> <items> <item> <title>Item</title> <details> <data xmlns="http://some_url"> <length>10</length> <weight>1.2</weight> </data> </details> </item> </items> </root> Following XPath does not work meaning nothing is printed like the "data" element does not exists: /root/items/item/details/data But when I remove "xmlns" namespace attribute of "data" element it's content is printed. How should the xpath expression look like to work without deleting "xmlns"

Unable to add namespace to an attribute with PHP's SimpleXML

别说谁变了你拦得住时间么 提交于 2019-12-17 07:38:05
问题 I am creating an Atom feed, when I tried below to add xmlns:i as an attribute - $node->addAttribute("xmlns:i","http://www.w3.org/2001/XMLSchema-instance"); I got this as an output - i="http://www.w3.org/2001/XMLSchema-instance" "xmlns:" part was cut off. do I need to escape the : -character? Or is they any other way to add this namespace? 回答1: If you want to add an attribute from the namespace/prefix i to $node don't bother declaring the namespace beforehand. Just use the third parameter of

Why this line xmlns:android=“http://schemas.android.com/apk/res/android” must be the first in the layout xml file?

本秂侑毒 提交于 2019-12-17 04:11:05
问题 Why is this line needed in xml layout file? xmlns:android="http://schemas.android.com/apk/res/android" 回答1: In XML, xmlns declares a Namespace. In fact, when you do: <LinearLayout android:id> </LinearLayout> Instead of calling android:id , the xml will use http://schemas.android.com/apk/res/android:id to be unique. Generally this page doesn't exist (it's a URI, not a URL), but sometimes it is a URL that explains the used namespace. The namespace has pretty much the same uses as the package

How to serialize an object to XML without getting xmlns=“…”?

无人久伴 提交于 2019-12-17 03:58:42
问题 Is there a way for me to serialize an object in .NET without the XML Namespaces automatically serializing also? It seems that by default .NET believes the XSI and XSD namespaces should be included, but I don't want them there. 回答1: Ahh... nevermind. It's always the search after the question is posed that yields the answer. My object that is being serialized is obj and has already been defined. Adding an XMLSerializerNamespace with a single empty namespace to the collection does the trick. In

What does elementFormDefault do in XSD?

谁说我不能喝 提交于 2019-12-17 03:01:50
问题 What does elementFormDefault do, and when should it be used? So I found some definitions for elementFormDefault values: qualified - elements and attributes are in the targetNamespace of the schema unqualified - elements and attributes do not have a namespace So from that definition I would think that if a schema is set to qualified then why must you prefix the type with the namespace? And what are the scenarios that you would even have one set to unqualified for that matter? I tried Googling,