xml-namespaces

How to remove xmlns attribute from XDocument?

橙三吉。 提交于 2019-11-30 13:40:41
In my C# codebase, I have an XDocument of the form: <A> <B> <C xmlns='blabla' yz='blablaaa'> Hi </C> <D xmlns='blabla' yz='blablaaa'> How </D> <E xmlns='blabla' yz='blablaaa'> Are </E> <F xmlns='blabla' yz='blablaaa'> You </F> </B> <B> <C xmlns='blabla' yz='blablaaa'> I </C> <D xmlns='blabla' yz='blablaaa'> am</D> <E xmlns='blabla' yz='blablaaa'> fine</E> <F xmlns='blabla' yz='blablaaa'> thanks</F> </B> Using Linq-to-XML or otherwise, I wanted to remove the xmlns for all the elements contained by element B. Using the methodology given here: How to Remove specific attributes in XMLDocument? , I

Is xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” a special case in XML?

半腔热情 提交于 2019-11-30 13:37:47
When we use a namespace, we should also indicate where its associated XSD is located at, as can be seen in the following example: <?xml version="1.0"?> <Artist BirthYear="1958" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.webucator.com/Artist" xsi:schemaLocation="http://www.webucator.com/Artist Artist.xsd"> <Name> <Title>Mr.</Title> <FirstName>Michael</FirstName> <LastName>Jackson</LastName> </Name> </Artist> Here, we have indicated that Artist.xsd should be used for validating the http://www.webucator.com/Artist namespace. However, we are also using the http://www

Why is there no XPath syntax for namespace-qualified nodes?

非 Y 不嫁゛ 提交于 2019-11-30 11:31:44
Some of the nodes in an XML document have namespaces, specified with a defined prefix. It is possible to specify local-name() in XPath 1.0 and so ignore namespaces. However, I want to enable the writer of the XPath to find nodes using their full namespace-qualified name as an identifier. The recommended way is to add namespace declarations in the invoking code (in my case, Java). But this means that the person writing Xpath does not have the ability to work with namespaces! How do we find nodes by their fully qualified names using pure XPath? Not sure what you meant by "as an identifier". How

How to remove namespace from the output xml?

点点圈 提交于 2019-11-30 11:22:54
Below is my xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://www.test.com/schemas/test" xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <XMLResponse> <xsl:apply-templates select="ms:ProductRS/ms:Product"/> </XMLResponse> </xsl:template> <-- some templates here --> </xsl:stylesheet> In the output i getting like below <?xml version="1.0" encoding="UTF-16"?> <XMLResponse xmlns:xsi="http://www.w3.org

Set up my own XML namespace?

穿精又带淫゛_ 提交于 2019-11-30 09:17:40
How can I setup my own XML namespace? Just define a namespace in the root tag (or wherever you need the namespace). Example: <root xmlns:ns="some_identifier"> ns and the identifier can be (nearly) anything. See this quote : What Do Namespace Names Point At? One of the confusing things about all this is that namespace names are URLs; it's easy to assume that since they're Web addresses, they must be the address of something. They're not; these are URLs, but the namespace draft doesn't care what (if anything) they point at. Think about the example of the XML.com programmer looking for book

XML: do child nodes inherit parent's namespace prefix?

断了今生、忘了曾经 提交于 2019-11-30 08:20:42
Assume the following XML document: <root xmlns:foo="..."> <foo:parent> <child/> </foo:parent> </root> does child element belong to a namespace that corresponds to the prefix foo ? Just like in case <foo:child/> ? No. Child nodes do not inherit prefixed namespace by default, and explicit prefix addition needed as you mentioned : <foo:child/> . But they do inherit ancestor's default namespace (the one without prefix), if any : <root xmlns:foo="..."> <parent xmlns="bar"> <child/> </parent> </root> <parent> and <child> nodes are in the same namespace which URI is bar . 来源: https://stackoverflow

XSL - copy elements but remove unused namespace(s)

北慕城南 提交于 2019-11-30 06:26:44
I've got some XML which declares a namespace which is only used for attributes, like this: <?xml version="1.0" encoding="UTF-8"?> <a xmlns:x="http://tempuri.com"> <b> <c x:att="true"/> <d>hello</d> </b> </a> I want to use XSL to create a copy of selected nodes and their values - getting rid of the attributes. So my desired output is: <?xml version="1.0" encoding="UTF-8"?> <b> <c /> <d>hello</d> </b> I've got some XSL that almost does this, but I can't seem to stop it putting the namespace declaration in the top level element of the output. My XSL is: <?xml version="1.0" encoding="UTF-8"?> <xsl

How do I use XPath with a default namespace with no prefix?

二次信任 提交于 2019-11-30 06:24:43
问题 What is the XPath (in C# API to XDocument.XPathSelectElements(xpath, nsman) if it matters) to query all MyNodes from this document? <?xml version="1.0" encoding="utf-8"?> <configuration> <MyNode xmlns="lcmp" attr="true"> <subnode /> </MyNode> </configuration> I tried /configuration/MyNode which is wrong because it ignores the namespace. I tried /configuration/lcmp:MyNode which is wrong because lcmp is the URI, not the prefix. I tried /configuration/{lcmp}MyNode which failed because Additional

Namespace agnostic XPath query with element content

a 夏天 提交于 2019-11-30 05:10:12
问题 The namespace agnostic syntax I've seen around is confusing me. Say I have: <root> <parent attribute="A">A<child>A</child></parent> <parent attribute="B">B<child>B</child></parent> </root> So far I see how: /root/parent/child/text() translates to: /*[local-name()='root']/*[local-name()='parent']/*[local-name()='child']/text() but i'm struggling with things like this: /root/parent[@attribute="A"]/child/text() or: /root/parent[text()="B"]/child/text() or: /root/parent[1]/child/text() How do

Using XSDs with includes

為{幸葍}努か 提交于 2019-11-30 04:52:16
Here is an XSD: <?xml version="1.0"?> <xsd:schema elementFormDefault='unqualified' attributeFormDefault='unqualified' xmlns:xsd='http://www.w3.org/2001/XMLSchema' > <xsd:simpleType name='TheSimpleType'> <xsd:restriction base='xsd:string' /> </xsd:simpleType> </xsd:schema> Here is a second XSD that includes the one above: <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema elementFormDefault='unqualified' attributeFormDefault='unqualified' xmlns:xsd='http://www.w3.org/2001/XMLSchema' targetNamespace='a' xmlns='a' > <xsd:include schemaLocation='Include.xsd' /> <xsd:element name = "TheElement" >