xml-namespaces

Why are XML namespaces HTTP addresses?

自作多情 提交于 2019-12-02 01:09:00
Even though namespace URIs are not real resources available over HTTP, what is the purpose of XML namespaces? And how are XML parsers related to it? Where their recognition (namespaces) exist? The purpose of XML namespaces is explained clearly in Section 1, Motivation and Summary of the W3C Recommendation: Namespaces in XML 1.0 (Third Edition) : We envision applications of Extensible Markup Language (XML) where a single XML document may contain elements and attributes (here referred to as a "markup vocabulary") that are defined for and used by multiple software modules. One motivation for this

Selecting namespaced XML node attributes with namespace alias instead of URI on an XElement

故事扮演 提交于 2019-12-02 00:04:09
I'm trying to query out some information from a heavily namespaced XML document and am having some trouble finding attributes that are also namespaced. The XML looks like: <?xml version="1.0" encoding="utf-8" ?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:geo="http://www.geonames.org/ontology#" xmlns:dc="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:void="http://rdfs.org/ns/void#"> <geo:Country rdf

Extract XML namespace declarations into separate tagfile/taglib

…衆ロ難τιáo~ 提交于 2019-12-01 23:04:22
I would like to seperate my XML namespace declarations at the top of the page into a seperate (tag)file in which I can include in any Facelets page I wish. Is this possible? Or do I need to copypaste all XML namespaces in each Facelets file? Here's a theoretical example, xmlns.xhtml : <something xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" ... /> And the template file which could use it: mypage.xhtml : <f:view xmlns="xmlns.xhtml"> <h:head

Using XPath to extract XOM elements from documents with unnecessary namespaces

情到浓时终转凉″ 提交于 2019-12-01 22:48:40
I'm trying to parse some HTML returned by an external system with XOM. The HTML looks like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <body> <div> Help I am trapped in a fortune cookie factory </div> </body> </html> (Actually it's significantly messier, but it has this DOCTYPE declaration and these namespace and language declarations, and the HTML above exhibits the same problem as the real HTML.) What I want to do is extract the content of

XInclude Schema/Namespace Validation?

点点圈 提交于 2019-12-01 22:28:50
I'm trying to use XML Includes to help manage a large XML structure that needs to be usable by both humans and machines. But am experiencing a myriad of problems when trying to construct XML files that can be validated against an existing schema. Here's a simplified example of what I'm trying to do. My "main.xml" file does not validate. <?xml version="1.0" encoding="UTF-8"?> <!-- Main.xml - This fails to validate. --> <ns1:main xsi:schemaLocation="http://www.example.com/main main.xsd" xmlns:ns1="http://www.example.com/main" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http:/

Is it possible to have multiple namespace prefixes in XML?

笑着哭i 提交于 2019-12-01 22:05:00
问题 I would like to do something like this: <root:secondlevel:thirdlevel xmlns:secondlevel="http://secondlevel.com" xmlns:secondlevel:thirdlevel="http://thirdlevel.com"> </root:secondlevel:thirdlevel> Is there a way to do those multiple levels root:secondlevel:thirdlevel as valid XML? 回答1: No, there can be at most one namespace prefix in XML. The XML Namespace BNF rules for names are based on QName, which allows only a single PrefixedName : QName ::= PrefixedName | UnprefixedName PrefixedName ::=

How to add namespace to xml using linq xml

醉酒当歌 提交于 2019-12-01 21:48:24
Question update: im very sorry if my question is not clear here is the code im using right now XDocument doc = XDocument.Parse(framedoc.ToString()); foreach (var node in doc.Descendants("document").ToList()) { XNamespace ns = "xsi"; node.SetAttributeValue(ns + "schema", ""); node.Name = "alto"; } and here is the output <alto p1:schema="" xmlns:p1="xsi"> my goal is like this xsi:schemaLocation="" where does the p1 and xmlns:p1="xsi" came from? When you write XNamespace ns = "xsi"; That's creating an XNamespace with a URI of just "xsi". That's not what you want. You want a namespace alias of xsi

python lxml findall with multiple namespaces

我的未来我决定 提交于 2019-12-01 21:42:37
I'm trying to parse an XML document with multiple namespaces with lxml, and I'm stuck on getting the findall() method to return something. My XML: <MeasurementRecords xmlns="http://www.company.com/common/rsp/2012/07" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.company.com/common/rsp/2012/07 RSP_EWS_V1.6.xsd"> <HistoryRecords> <ValueItemId>100_0000100004_3788_Resource-0.customId_WSx Data Precip Type</ValueItemId> <List> <HistoryRecord> <Value>60</Value> <State>Valid</State> <TimeStamp>2016-04-20T12:40:00Z</TimeStamp> </HistoryRecord> </List> <

Declare namespaces within XPath expression

江枫思渺然 提交于 2019-12-01 20:41:32
问题 My application needs to evaluate XPath expression against some XML data. Expression is provided by user at runtime. So, I cannot create XmlNamespaceManager to pass to XPathEvaluate because I don't know prefixes and namespaces at compile time. Is there any possibility to specify namespaces declaration within xpath expression? Answers to comments: XML data has one default namespace but there can be nested elements with any namespaces. User knows namespaces of the data he works with. User

How do I add a namespace prefix to each node using TXMLDocument

和自甴很熟 提交于 2019-12-01 20:23:39
I used the XML Binding Wizard to create a descendant of TXMLDocument. The files generated by this class would declare the namespace in the root node and create just plain, unadorned nodes for the rest of the document. <?xml version="1.0"?> <RootNode xmlns="URL" xmlns:xsi="URL" xsi:schemaLocation="URL"> <SomeNode> <AnotherNode>Value</AnotherNode> </SomeNode> </RootNode> I've had no trouble reading or validating this at all. However, the processor where these files are sent now requires each node to have the namespace prefixed in order to process files correctly. <?xml version="1.0"?> <NS