In xades4j, in case of multiple enveloping signature i will have my signed document with, at the end, more Signature elements, but i need to tell to each reference to signed document (URI="") that he must not refers to other Signature element that represent other Signature, i need so to add this transformation
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
<dsig-xpath:XPath Filter="subtract">/descendant::ds:Signature</dsig-xpath:XPath>
</ds:Transform>
</ds:Transforms>
....
Telling that it must not to consider ds:Signature element for signature production.
How xades4j permit the use of this kind of transformation?
Thanks
Michele
You can add the transforms when defining the DataObjectReference. Check the examples on the wiki page and the XPath2FilterTransform class documentation.
Related
I have the following XML:
<envelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="vendor">
<fizz buzz="3"/>
</payload>
</envelope>
I am trying to write an XPath expression that will pluck out vendor (value for the payload's class attribute) or whatever its value is.
My best attempts are:
/dataEnvelope/payload[#class="vendor"]#class
But this requires the expression to already know that vendor is the value of the attribute. But if the XML is:
<dataEnvelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="foobar">
<fizz buzz="3"/>
</payload>
</dataEnvelope>
Then I want the expression to pluck out the foobar. Any ideas where I'm going awry?
If you need #class value from payload node, you can use
/dataEnvelope/payload[#class]/#class
or just
/dataEnvelope/payload/#class
At first, your two XML files are out-of-sync - one references envelope and the other references dataEnvelope. So exchange one for the other, if necessary.
So, to get the attribute value of payload, you can use an XPath expression like this which uses a child's attribute value to be more specific:
/envelope/payload[fizz[#buzz='3']]/#class
Output is:
vendor
If the document element can/will change, then you can keep the XPath more generic and select the value of the class attribute from the payload element that is a child of any element:
/*/payload/#class
If you know that it will always be a child of envelope, then this would be more specific(but the above would still work):
/envelope/payload/#class
With XML Schema we can define ID/IDREF links between components in an XML document. I'm looking for a way, using XPath, to ensure that only certain IDs can be used as IDREFs - i.e. only those values which logically make senses in the context of the schema design.
Using the example below, how do I ensure that a book's library_id is actually one of the available library_ids and not some other id which could appear in the message and be used for some entirely different purpose (but still be schema valid).
<books>
<book library_id="lib1">
<author>A</author>
<title>B</title>
</book>
<book library_id="lib2">
<author>C</author>
<title>D</title>
</book>
<library id="lib1">
<name>X</name>
<city>Y</city>
</library>
<library id="lib2">
<name>X</name>
<city>Y</city>
</library>
</books>
The closest I've come to getting this to work is to use the XPath contains function e.g.
contains(//library/#id,//book/#library_id)
but this throws an error because a sequence of more than one item is not allowed as the first argument of contains() ("lib1","lib2").
Thanks
I hope that understood correctly what you want
Books with library_id present in library list
//book[#library_id = //library/#id]
Books with incorrect library_id
//book[not(#library_id = //library/#id)]
Why not use XSD's key/keyref constraints instead of ID/IDREF? These are much more flexible: they can be scoped to any element rather than the whole document; you can have different kinds of IDs within a document and the refs must match up to the same kind; the values can be composite (e.g. first name + last name); the values can be of any data type.
The header file CoreAudio/AudioHardware.h refers to a class "AudioBox" and indicates that it is distinct from but related to the class "AudioDevice". Searching developer.apple.com yields no hits for AudioBox. There is, unfortunately, a commercial product called AudioBox™, which makes googling for the term painfully low-yield.
Here are the comments containing the references:
kAudioHardwarePropertyBoxList
An array of AudioObjectIDs that represent all the AudioBox
objects currently provided by the system.
kAudioHardwarePropertyTranslateUIDToBox
This property fetches the AudioObjectID that corresponds to the
AudioBox that has the given UID. The UID is passed in via the qualifier as a CFString while the AudioObjectID for the AudioBox is
returned to the caller as the property's data. Note that an error
is not returned if the UID doesn't refer to any AudioBoxes.
Rather, this property will return kAudioObjectUnknown as the value of the property.
The header file: AudioHardwareBase.h contains numerous references to AudioBox, but does not define or explain it, although it associates it with AudioDevice.
Searching the docs via XCode just takes me back to AudioHardwareBase.h.
I can infer that perhaps an "AudioBox" is an audio device that is accessed via a plugin. But this does not appear to be stated anywhere.
So What Is An AudioBox?
An AudioBox is a container of (usually) AudioDevices
My question basically is the same as this question.
I don't have enough reputation to add a comment to the OP's question. Please help
The problem I'm having is:
The SOAP web service I'm trying to call requires the header to have two elements, one containing basic header data and another with synchronisation specific data, the header that's required looks like this :
<header>
<initHeader>
<requestID></requestId>
<...some more elements>
</initHeader>
<syncHeader>
<appId></appId>
<dateTime></dateTime>
<event></event>
</syncHeader>
</header>
When generating the header using WebServiceMessageCallback (specifically during the transformation shown below), I get this:
"ERROR: 'The markup in the document following the root element must be well-formed.'"
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new StringSource(soapHeaderStr), ((SoapMessage) message).getSoapHeader().getResult());
The issue here is that the transformer expects all the elements in the header to be under one root element. But here, the header has two.
I changed the header data like this(below) and the transformer does not complain.
<header>
<myRootelement>
<initHeader>
<requestID></requestId>
<...some more elements>
</initHeader>
<syncHeader>
<appId></appId>
<dateTime></dateTime>
<event></event>
</syncHeader>
</myRootelement>
</header>
According to the above mentioned question, the OP had solved this problem by addigng a dummy root element as above and then removing it just before transforming it into the header.
I want to know how this removal of the dummy root elements is possible ? Something like this may be ? http://technology.amis.nl/2011/05/16/how-to-remove-unwanted-soap-header-elements-in-jax-ws/
I'm not quite sure how to remove a root element while keeping its children intact.
Managed to solve the problem, Here's how :
Instead of marshalling the two elements into StringResult objects and then trying to add them to the header using a the Transformer like this :
StringResult stringResult = new StringResult();
webServiceTemplate.getMarshaller().marshal(element, stringResult);
StringSource headerSource = new StringSource(stringResult.toString());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(headerSource, soapHeader.getResult());
You can marshal the two elements directly into the soap header like this :
webServiceTemplate.getMarshaller().marshal(element1,soapHeader.getResult());
webServiceTemplate.getMarshaller().marshal(element2,soapHeader.getResult());
The marshaller mentioned here is a "org.springframework.oxm.jaxb.Jaxb2Marshaller"
The element 1 and 2 above are the JAXB elements created using the generated Object factory class.
With this approach, there is no need to add dummy root elements.
Hope this helps someone out there, and thanks to Grigori.G for pointing me in the right direction !
How do I tell the Zend_Form that I want an element (and it's ID-label, etc) to use another ID value instead of the element's name?
I have several forms in a page. Some of them have repeated names. So as Zend_Form creates elements' IDs using names I end up with multiple elements with the same ID, which makes my (X)HTML document invalid.
What is the best solution to fix this, given that I really have to stick with using the same element names (they are a hash common to all forms and using the Zend_Form Hash Element is really out of question)?
Zend_Form_Element has a method called setAttribs that takes an array. You may be able to do something like $element->setAttribs(array('id' => "some_id"));
or you can do $element->setAttrib('id', 'some_id');
Thanks, Chris Gutierrez.
However, as I said, I needed to get ride of the default decorator generated IDs like -label. Wiht the $element->setAttribs() it is not possible, however.
So based on http://framework.zend.com/issues/browse/ZF-7125 I just did the following:
$element->clearDecorators();
$element->setAttrib('id', 'some_id');
$element->addDecorator("ViewHelper");
Whoever sees this: please note this was enough for what I needed. But may not be for you (the default settings has more than the viewHelper decorator).