Different namespace for xades:QualifyingProperties - xades4j

When I sign an XML document I get:
<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" Target="#xmldsig-0497c0ca-641b-4e41-8ee8-bf223afabea1">
<xades:SignedProperties Id="xmldsig-0497c0ca-641b-4e41-8ee8-bf223afabea1-signedprops">
....
</xades:SignedProperties>
</xades:QualifyingProperties>
What can I do to get xmlns:xades="http://uri.etsi.org/01903/v1.1.1#"?

xades4j is based on version 1.4.1 of XAdES. The namespace can't simply be changed, as the XML structure would be different.

Related

How to add own namespace in Yii2

I have changed Yii2 advanced directory structure like following(it's working well):
app-folder
-admin
-assets
-.htaccess
-index.php
-assets
-protected
-backend
...
-common
...
-frontend
...
...
-uploads
...
Now, I am trying to add a namespace as namespace protected\base; into protected/base/AnyFile.php file and use it in a controller as use protected\base\AnyFile;. But, my project is giving error:
syntax error, unexpected 'protected' (T_PROTECTED), expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\ (T_NS_SEPARATOR)
I saw this issue on the website: Yii2 Custom / Shorter Namespace. However, It didn't work on my condition.
First of all protected is reserved keyword (token T_PROTECTED). You can keep direcory name but you need to change namespace root alias.
In your alias config file protected/common/bootstrap.php write:
Yii::setAlias('app', dirname(dirname(__DIR__))); // set path to protected directory
And then use namespace app\base; and use app\base\AnyFile;.
See Class Autoloading section of the guide https://www.yiiframework.com/doc/guide/2.0/en/concept-autoloading

Adam' object has no attribute 'zero_grads'

Im using a code not writing by me. So when executing this code we get error about the inexistance of zero_grads()
optimizer.zero_grads()
AttributeError: 'Adam' object has no attribute 'zero_grads'
This code is:
import chainer.optimizers as O
optimizer = O.Adam()
optimizer.setup(model)
clip = chainer.optimizer.GradientClipping(5.0)
optimizer.add_hook(clip)
....
optimizer.zero_grads()
optimizer.update()
Does i should change: optimizer.zero_grads()
to
optimizer.use_cleargrads(use=True)?
Note that im using chainer 4.0 version and the code what building with chainer 1.5.
optimizer's method zero_grads are deprecated and deleted, now it is preferable to use Link's method cleargrads.
So I guess you should change optimizer.zero_grads() to model.cleargrads()
Also, Refer
AttributeError: 'MomentumSGD' object has no attribute 'zero_grads'
However, when you want to use the code written in chainer v1.5, there may be several other places you need to update for chainer v4. It might be better to try executing the code with chainer v1.5 to see the behavior at first.

Why while querying ontologies we have to load the ontology, also provide its namespace?

I wonder why we have to load an ontology, also provide its namespace while querying it? Why loading the ontology is not enough?
To understand my question better, here is a sample code:
g = rdflib.Graph()
g.parse('ppp.owl', format='turtle')
ppp = rdflib.Namespace('http://purl.org/xxx/ont/ppp/')
g.bind('ppp', ppp)
In line 2, we have opened the ontology (ppp.owl), but in line 3 we also provided its namespace. Does namespace show the program how to handle the ontology?
Cheers,
RF
To specify an element over the semantic web you need its URI: Unique Resource Identifier, which is composed of the namespace and the localname. For example, consider Person an RDF class; how would you differentiate the Person DBpedia class http://dbpedia.org/ontology/Person from Person in some other ontology somewhere? you need the namespace http://dbpedia.org/ontology/ and the local name Person. Which both uniquely identify the class.
Now coming back to your specific question, when you query the ontology, you might use multiple namespaces, some namespaces may not be the one of your ontology. You need other namespaces for querying your own ontology, e.g. rdf, rdfs, and owl. As an example, you can rarely write an arbitrary query without rdf:type property, which is included under the rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns> namespace, not your ontology namespace. As a consequence, you need to specify the namespace.
Well, now as you should know why to use a namespace, then we can proceed. Why to repeat the whole string of the namespace each time it is needed? It is nothing more than a prefix string appended to the local names to use in the query, to avoid writing exhaustively the full uri. See the difference between <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> and type.
Edit
As #AKSW says, as a conclusion, there is no need to declare a namespace in order to work with the ontology but it increases the convenience when working quite often with resources whose URI has particular namespace.

Doctrine2 Entity Namespace

i'm new to Doctrine2 and like to know how i can tell Doctrine which namespace my entities use.
My current configuration is this.
All my entities are in namespace "project\entity".
So, everytime i want to obtain the entity "Color", i have to write:
$em->getRepository("project\\entity\\Color")
How can i configure Doctrine to always use namespace "project\entity"?
You can come close to what you want by using addEntityNamespace on your config object to create a namespace alias:
$em->getConfiguration()->addEntityNamespace('NS1', 'Project\Entity');
$colorRepo = $em->getRepository('NS1:Color');
Works for queries as well.
By the way, "project\\entity\\Color" can also be written as 'project\entity\Color'. I would also suggest capitalizing Project and Entity just to conform to standards.

How do XQuery function namespaces work?

EDIT
I want to group together related functions to show that they are related.
If I have local:f1() and local:f2() then I could just change their names to local:menu-f1() and local:menu-f2() but is there a mechanism in the XQuery language to group related functions?
OP
I am very excited to discover that XQuery functions can be declared in a namespace other than local:. Where can I find info about how this works?
Having always declared functions in this way;
declare function local:foo() {
3+4
};
.. and used them in this way;
local:foo()
.. I discover that they can be declared like this;
declare namespace baz = "fred:bloggs";
declare function baz:foo() {
3+4
};
.. and used like this;
baz:foo()
But I can only find reference-like information about declare namespace and declare function separately, not tutorial-like information about how XQuery function namespaces work in general.
Is there a newbie guide to XQuery function namespaces?
I'm using a Saxon processor - XQuery 1.0.
What you are probably using are normal XQuery namespaces - what you probably are looking for are modules. You can put a bunch of functions in its own module namespace like this:
module namespace foo = "http://www.myurl.com/foo";
declare function foo:bar($args as item()*) as item()* {
() (: do something cool :)
};
Afterwards you can import the module in you main query and call the function:
import module namespace foo = "http://www.myurl.com/foo";
foo:bar(<my-element/>)
The problem is, that it is not standardized, how the processor has to find the query. And I don't know how Saxon implements the module resolving mechanism (you should look into the documentation and/or write to the Saxon mailing list).
But most XQuery processors look at the path given by an "at" clause relative from the location of the query. So to have something that should work on most implementations: For example you could store the module in a file named foo.xq and place it into the same directory than your main query and then for the module import you would write:
import module namespace foo = "http://www.myurl.com/foo" at "foo.xq";
which gives a hint to the XQuery engine where it should look for the module.
You can find some (not a lot at the moment) documentation about this stuff at http://www.xquery.me/ - hope this helps.
EDIT
Ok I see, you only want to group your functions. To do that you already figured out everything you need to know. But I still want to emphasize that splitting your query up into modules would probably be the better solution for your use-case (it's just somehow nicer, since your have more modularity and in the upcoming XQuery 3.0 recommendation you will even have the possibility to put stuff like private functions and variables in there). But if your query does not get big, your solution is of course also ok.
You can think about XML namespaces the same way you would think about namespaces in C++. In XQuery, functions, elements, collections, variables, attributes etc can be in an own namespace (again - like in C++). There are some implicitely defined namespaces like xs (the XML Schema namespace where you can find the data types like boolean, integer etc), local (a namespace where you can put in functions so that you are not forced to define your own namespace in a main query), fn (where all functions from the "XQuery 1.0 and XPath 2.0 functions and operators" recommendation are defined). But the prefix of this function is only an alias - you can use whatever you want.
So let's say you have the following code in the prolog of your query:
declare namespace blubb = "http://www.w3.org/2001/XMLSchema";
blubb:integer would be exactly the same type than xs:integer - the same holds for functions:
declare namespace l = "http://www.w3.org/2005/xquery-local-functions";
With declaring that you can access every function in the local namespace with the "l" prefix (so l:bar() if local:bar() exists).
If you do not type a prefix, XQuery assumes that this function is in the "fn" namespace. This is why bot
fn:concat("Hello ", "World!")
and
concat("Hello ", "World!")
are equivalent. You can change this behavior. You could include this line into the prolog:
declare default function namespace "http://www.w3.org/2005/xquery-local-functions";
which would tell the XQuery processor that you do not want to prefix local functions (so bar() would be equivalent to local:bar()).
I am not sure if I answered your questions or at least was able to bring in some clarity. I do not know about a tutorial for that (since in the beginning it is somehow confusing but in the end you realize that there is not a lot to say about since the mechanisms are much simpler than they look in the first place). The document where I always look up stuff is the recommendation at http://www.w3.org/TR/xquery/
If this does not help you please try to qualify and I can try again with an explanation..