RDF and uuid. why no urn schema? - uri

<rdf:Description about='uuid:8949dbc6-31ad-11d9-9c7d-d112c21f7031'>
Why this about does not contain urn:uuid:8949dbc6-31ad-11d9-9c7d-d112c21f7031 instead? Isn't the uuid a urn, and therefore required to have a urn: scheme in front of it ?

Following the chain of specifications, the IANA URN namespace registry does indeed register 'uuid' as a namespace after 'urn:'. So yes, the URL above is wrong and it should start 'urn:uuid' as you were expecting.

This URI is wrong. Using the following RDF document in the W3C RDF Validator returns an error
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about='uuid:8949dbc6-31ad-11d9-9c7d-d112c21f7031'>
<dc:title>Hello</dc:title>
</rdf:Description>
</rdf:RDF>
Error: {W102} unqualified use of rdf:about is deprecated.[Line = 4, Column = 70]

Related

Implementing WebDAV ACL: should I modify or replace access entries?

Let's suppose I do ACL method on a resource for the first time:
<?xml version="1.0" encoding="utf-8" ?>
<D:acl xmlns:D="DAV:">
<D:ace>
<D:principal>
<D:href>http://www.example.com/users/esedlar</D:href>
</D:principal>
<D:grant>
<D:privilege><D:write/></D:privilege>
</D:grant>
</D:ace>
</D:acl>
And then on the same resource for a second time:
<?xml version="1.0" encoding="utf-8" ?>
<D:acl xmlns:D="DAV:">
<D:ace>
<D:principal>
<D:href>http://www.example.com/users/esedlar</D:href>
</D:principal>
<D:grant>
<D:privilege><D:read/></D:privilege>
</D:grant>
</D:ace>
</D:acl>
Should D:write be retained for http://www.example.com/users/esedlar after request #2?
RFC extract: https://www.rfc-editor.org/rfc/rfc3744#page-40
Specifically, the ACL
method only permits modification to ACEs that are not inherited, and
are not protected. An ACL method invocation modifies all non-
inherited and non-protected ACEs in a resource's access control list
to exactly match the ACEs contained within in the DAV:acl XML element
(specified in Section 5.5) of the request body. An ACL request body
MUST contain only one DAV:acl XML element. Unless the non-inherited
and non-protected ACEs of the DAV:acl property of the resource can be
updated to be exactly the value specified in the ACL request, the ACL
request MUST fail.

how to save payload of soa composite to xml file?

i am working on oracle SOA project in which i want to save csv data to XML file. till now i got the payload in form of xml using Translate activity but i can only use it directly. I want to save the pay load to xml file.
i am facing following error :
<?xml version="1.0" encoding="UTF-8"?><bpelFault>
<faultType>0</faultType>
<subLanguageExecutionFault xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
<part name="summary">
<summary>An error occurs while processing the XPath expression; the expression is ora:doXSLTransformForDoc("../Transformations/Transformation.xsl", $Receive_Read_InputVariable.body)</summary>
</part>
<part name="code">
<code>XPath expression failed to execute</code>
</part>
<part name="detail">
<detail>XPath expression failed to execute.
An error occurs while processing the XPath expression; the expression is ora:doXSLTransformForDoc("../Transformations/Transformation.xsl", $Receive_Read_InputVariable.body)
The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: oramds:/deployed-composites/default/CSV_To_XML_rev1.0/Transformations/Transformation.xsl<Line 30, Column 109>: XML-22031: (Error) Variable not defined: 'oracle_empty_param'.
Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
</detail>
</part>
</subLanguageExecutionFault>
</bpelFault>
I am working with oracle soa suite 12c.
It sounds like you want to convert a variable to a string. I would use an XSL transform. Input to the transform would be your newly translated variable and the output be a plain old String variable. The transform would look like this:
<xsl:template match="/">
<tns:myString>
<xsl:copy-of select="/ns0:RootElement"/>
</tns:myString>
</xsl:template>
If you wanted to, you could then write this string to the file adapter

How do I filter with OData based on an inner array?

So I created a controller using the mvc4 web api where the url (Get) “/api/things” return the following data:
<ArrayOfThing>
<Thing>
<Id>1</Id>
<Description>The Thing Desc</Description>
<Categories>
<Category><Id>1</Id></Category>
<Category><Id>2</Id></Category>
</Categories>
</Thing>
<Thing>
<Id>2</Id>
<Description>The Other Thing Desc</Description>
<Categories>
<Category><Id>1</Id></Category>
<Category><Id>3</Id></Category>
</Categories>
</Thing>
</ArrayOfThing>
*note that thing and categories has a many to many relationship
I know that if a need one “Thing” resource I should use a controller that matches the following route url (Get) “/api/things/{id}”.
But what if I want to get a subset of the data returned by the url (Get) “/api/things”. I tested the OData protocol modifying the controller to return an IQueryable and it work fine if I wanted to $filter on the properties of “Thing” like the Id or the Description. Unfortunately, I didn’t work out when I wanted to filter base on the Category, I believe is because Categories is an inner array.
So, what should I do to filter based on categories?
OData V3 supports Any/All operations, which you can filter by a collection property. For example, to filter things which contains Category(1), using following syntax:
/api/things/?$filter=Categories/any(category: category/Id eq 1)
If you are using ASP.net Web Api RTM bits, you can use odata package to support any/all. For more examples, you can check the queryable sample code: http://aspnet.codeplex.com/SourceControl/changeset/view/61dfed023e50#Samples%2fNet4%2fCS%2fWebApi%2fODataQueryableSample%2fProgram.cs

Reference to undeclared namespace prefix when parsing MSXML

How do I solve the
Reference to undeclared namespace prefix: '%s'
problem with Microsoft's msxml implementation?
I'm using an XML feed from a government web-site that contains values i need to parse. The xml contains namespaces:
<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3c.org/1999/02/22-rdf-syntax-ns#rdf.xsd">
<item rdf:about="http://www.bankofcanada.ca/stats/rates_rss/STATIC_IEXE0101.xml">
<cb:statistics>
<cb:exchangeRate>
<cb:value decimals="4">1.0351</cb:value>
<cb:baseCurrency>CAD</cb:baseCurrency>
<cb:targetCurrency>USD</cb:targetCurrency>
<cb:rateType>Bank of Canada noon rate</cb:rateType>
<cb:observationPeriod frequency="daily">2011-05-09T12:15:00-04:00</cb:observationPeriod>
</cb:exchangeRate>
</cb:statistics>
</item>
</rdf:RDF>
Running the XPath query:
/rdf:RDF/item/cb:statistics/cb:exchangeRate/cb:targetCurrency
fails with the error:
Reference to undeclared namespace prefix: 'rdf'
Edit:
If i edit the original XML to remove all use of namespaces:
<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf>
<item>
<statistics>
<exchangeRate>
<value decimals="4">1.0351</value>
<baseCurrency>CAD</baseCurrency>
<targetCurrency>USD</targetCurrency>
<rateType>Bank of Canada noon rate</rateType>
<observationPeriod frequency="daily">2011-05-09T12:15:00-04:00</observationPeriod>
</exchangeRate>
</statistics>
</item>
</rdf>
The query /rdf/item/statistics/exchangeRate/baseCurrency doesn't fail, and returns nodes:
<baseCurrency>CAD</baseCurrency>
How do i get Microsoft XML to work with namespaces?
Edit 2
i've tried adding SelectionNamespaces to the DOMDocument object:
doc.setProperty('SelectionNamespaces', 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1"');
Now the xpath query doesn't fail, but it also returns no nodes:
nodes = doc.selectNodes('/rdf:RDF/item/cb:statistics/cb:exchangeRate/cb:targetCurrency');
See also
“undeclared reference to namespace prefix ” error
XMLReader - How to handle undeclared namespace
PRB: Specifying Fully Qualified Element Names in XPath Queries
XPath not working properly.
Using SelectionNamespaces is the correct approach, you are just missing a namespace.
Notice that your XML document explicitly sets the default namespace as follows:
xmlns="http://purl.org/rss/1.0/"
This means that any element without a prefix, such as the item element, is actually in the default namespace. So if you want to select that element with an XPath expression, you must first set an appropriate selection namespace.
To do this, you can change your call to setProperty like so:
doc.setProperty('SelectionNamespaces', 'xmlns:rss="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1"');
Here you've assigned the default namespace from the document to the rss: prefix in your XPath expression. With that change in place, the following XPath expression should work correctly:
nodes = doc.selectNodes('/rdf:RDF/rss:item/cb:statistics/cb:exchangeRate/cb:targetCurrency');
It works because it references the item element using the correct namespace. The fact that the prefix differs between the XPath expression and the original document is immaterial. It is the namespace which the prefix is bound to that matters.
doc.setProperty('SelectionNamespaces', 'xmlns:rss="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1"');
Dont forget to load the xsd file or schema to the xmldoc object
is the way to go
I dont have enough reputation to comment. But that bit there saved me a lot of time.
Thank you so much
If you are using XMLSerializer and see this error, it is likely that you are running into the IE bug described here:
https://stackoverflow.com/a/11399681
It took me a lot of time to realize that this was happening, so I thought it best to link these two issues.

issue with a xmlns

I have an xml file and an xslt file.
The xml file has a xmlns="exa:com.test" attribute.
If i remove this attribute in the xml the xpath sentences in my xslt works. But if i leave it, doesnt work.
Im using the following code to mix xml and xslt:
XslCompiledTransform transformer = new XslCompiledTransform();
transformer.Load(HttpContext.Current.Server.MapPath("xslt\\searchresults.xslt"));
transformer.Transform(xmlreader, null, utf8stringwriter);
What im doing wrong? How could i mix xml and xslt if the xml has the xmlns attribute on top?
The xmlns attribute without prefix name replaces the default namespace, so that your query matches nodes with a different (empty) namespace. You need to use a prefixed namespace in the XSLT XPath queries (or a XmlNamespaceManager for isolated XPath queries) and your queries will work again as expected.
In the XSLT:
<xsl:stylesheet ... xmlns:exa="exa:com.test">
Then, assuming that you used to match for instance xyz, you now change your query like this:
<xsl:template match="exa:xyz"> ...
In general you might want to read some docs on XML namespaces.
It should be noted though, though the namespace string is to just be seen as an exact literal string that is used as an identifier with no other meaning. The string must conform to an IANA uri, this is to guarantee uniqueness of namespaces. Some parsers refuse to parse namespaces that do not conform.
Also note that because they are strings http://www.w3.org/1999/xhtml and for instance http://w3.org/1999/xhtml/ are for the purposes of namespaces completely different namespaces.
You might want to read up on how namespaces in XML work. exa:com.test is as far as I know not a valid namespace string.

Resources