I'm making my own component, and I want to have oportunity to set some properties in form builder. In all I want to reach effect similar to autocomplete control, where I can set 3 properties (URI, xpath, and relative xpath). I read, that I can do it using control-details markup, but unfortunately it does not work. This is code (I working on davinci tutorial):
<xbl:binding element="fr|tutorial-davinci" id="fr-tutorial-davinci" xxbl:mode="lhha binding value">
<metadata xmlns="http://orbeon.org/oxf/xml/form-builder" xmlns:xf="http://www.w3.org/2002/xforms">
<display-name lang="en">davinci-modified</display-name>
<templates>
<instance label=""/>
<view>
<fr:tutorial-davinci id="" appearance="minimal" labelref="#label" xmlns="" resource="" >
<xf:label ref=""/>
<xf:hint ref=""/>
<xf:help ref=""/>
<xf:alert ref=""/>
</fr:tutorial-davinci>
</view>
</templates>
<control-details>
<xf:input>
<xf:label lang="en">Some param</xf:label>
</xf:input>
</control-details>
</metadata>
<xbl:template>
<xf:model>
<xf:instance id="id1"><value/></xf:instance>
</xf:model>
<xf:input ref="instance('id1')" />
</xbl:template>
</xbl:binding>
You must have a ref attribute on<xf:input> which points to an attribute or element where the information will be stored. In autocomplete.xml, there is in particular theresource` attribute, which:
is pointed to by <xf:input>
is present on the <fr:autocomplete> template
Related
I load this DMN file (dmnFile):
<definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns:ns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/">
<itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<typeRef>NumberDefinition</typeRef>
</itemComponent>
</itemDefinition>
<itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<typeRef>number</typeRef>
</itemDefinition>
<inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="MyItemDefinition" />
</inputData>
<decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<informationRequirement>
<requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</informationRequirement>
<context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<contextEntry>
<variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</text>
</literalExpression>
</contextEntry>
<contextEntry>
<literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<text>containsMyNumber</text>
</literalExpression>
</contextEntry>
</context>
</decision>
</definitions>
like this:
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.2"), ks.getResources().newFileSystemResource(dmnFile));
and I get an exception with the following error message:
[Message [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1
text=DMN: Unable to resolve type reference '{http://www.omg.org/spec/DMN/20180521/MODEL/}NumberDefinition' on node 'MyItemDefinition' (resource: C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, DMN id: _29d92e98-3c97-67a3-22f1-d342622424f7, The listed type definition was not found) ]]
Type reference with prefix ("ns:NumberDefinition") results in the following error message:
[Message [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1
text=DMN: Unable to resolve type reference '{http://www.omg.org/spec/DMN/20180521/MODEL/}ns:NumberDefinition' on node 'MyItemDefinition' (resource: C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, DMN id: _29d92e98-3c97-67a3-22f1-d342622424f7, The listed type definition was not found) ]]
What do I do wrong?
When using DMN 1.1 (xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd") and type references as QNames (with prefixes) I get the expected result.
Since DMNv1.2, the idiomatic way to reference is ns.<itemDef>.
In your original DMN xml file this happens on line 7 and 14.
In summary the file in the idiomatic DMNv1.2 form should be:
<definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns:ns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/">
<itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<typeRef>ns.NumberDefinition</typeRef>
</itemComponent>
</itemDefinition>
<itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<typeRef>number</typeRef>
</itemDefinition>
<inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="ns.MyItemDefinition" />
</inputData>
<decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<informationRequirement>
<requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</informationRequirement>
<context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<contextEntry>
<variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</text>
</literalExpression>
</contextEntry>
<contextEntry>
<literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<text>containsMyNumber</text>
</literalExpression>
</contextEntry>
</context>
</decision>
</definitions>
That said, with your report we uncovered a bug when the DMN xml file is using the DMN namespace as the default namespace, which we are addressing with
DROOLS-4797.
Thank you for the report !
There is a way to avoid being forced to use ns.<itemDef> and simply use <itemDef>, and that is by setting the default namespace in the DMN xml to be the model's namespace, and just prefixing the DMN xml element with the namespace prefix targeting the DMN namespace.
In other words, the file can make use of <itemDef> reference without having to ns. prefix them:
<semantic:definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns:semantic="http://www.omg.org/spec/DMN/20180521/MODEL/">
<semantic:itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<semantic:itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<semantic:typeRef>NumberDefinition</semantic:typeRef>
</semantic:itemComponent>
</semantic:itemDefinition>
<semantic:itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<semantic:typeRef>number</semantic:typeRef>
</semantic:itemDefinition>
<semantic:inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<semantic:variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="MyItemDefinition" />
</semantic:inputData>
<semantic:decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<semantic:variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<semantic:informationRequirement>
<semantic:requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</semantic:informationRequirement>
<semantic:context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<semantic:contextEntry>
<semantic:variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<semantic:literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<semantic:text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</semantic:text>
</semantic:literalExpression>
</semantic:contextEntry>
<semantic:contextEntry>
<semantic:literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<semantic:text>containsMyNumber</semantic:text>
</semantic:literalExpression>
</semantic:contextEntry>
</semantic:context>
</semantic:decision>
</semantic:definitions>
In this other variant, the default namespace in the xml is the DMN model's namespace, so any itemDef reference does not need any prefix.
Because the default namespace in the xml is the DMN model's namespace, the xml element need to be prefixed with the namespace prefix targeting now the DMN namespace.
Hope this clarifies and provide an insightful explanation!
I'm working on a project in react-admin and am trying to use an AutocompleteInputs within ReferenceInputs for Filter in a List. The list is a product that has a relationship with two different users, a consumer and provider. I'm currently able to obtain the choices for consumers and providers and filter my product list by either.
However, my issues arises with the autosuggestion. It's simply not working. Typing in the AutocompleteInput will not filter the choices to select from for either consumers or providers. I have another AutocompleteArrayInput within an ArrayReferenceInput for providers that's setup similarly and the autosuggestion is working perfectly fine.
Any thoughts?
Here's the broken AutocompleteInput:
export const ProductFilter = props => (
<Filter {...props}>
<ReferenceInput label="Consumer" reference="consumers"
source="consumer_user_id" allowEmpty>
<AutocompleteInput source="id" optionText={FullNameRenderer} />
</ReferenceInput>
<ReferenceInput label="Provider" reference="providers"
source="provider_user_id" alwaysOn allowEmpty>
<AutocompleteInput optionText={FullNameRenderer} />
</ReferenceInput>
<DateRangeInput alwaysOn />
</Filter>
)
And this is the working AutocompleteArrayInput:
export const ConsumerEdit = props => (
<Edit {...props}>
<TabbedForm redirect="show">
<FormTab label="Providers" path="provider_assignmenmts">
<ReferenceArrayInput label='Assigned Providers'
reference='providers' defaultValue={[]}
source="provider_ids" allowEmpty>
<AutocompleteArrayInput optionText={FullNameRenderer}/>
</ReferenceArrayInput>
</FormTab>
</TabbedForm>
</Edit>
)
In the component <AutocompleteInput source = "id" optionText = {FullNameRenderer} /> the attribute source = "id" is superfluous.
Well, it looks like this one is a larger issue within react-admin.
https://github.com/marmelab/react-admin/issues/3098
I'm trying to extend the modx modresource object, but keep getting errors & I can't seem to figure out why. It is related to the schema (I think) but everything looks correct.
Schema:
<?xml version="1.0" encoding="UTF-8"?>
<model package="extresource" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="modx_" version="1.0.0">
<object class="extResource" extends="modResource">
<composite alias="ResourceData" class="ResourceData" local="id" foreign="internalKey" cardinality="one" owner="local"/>
</object>
<object class="ResourceData" table="resource_data" extends="xPDOSimpleObject">
<field key="internalKey" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
<field key="views" dbtype="int" precision="11" phptype="integer" null="true" />
<field key="starred" dbtype="int" precision="10" phptype="integer" null="false" />
<index alias="internalKey" name="internalKey" primary="false" unique="true" type="BTREE" >
<column key="internalKey" length="" collation="A" null="false" />
</index>
<aggregate alias="Resource" class="modResource" local="internalKey" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>
I'm testing it using:
$resource = $modx->getObject('modResource', 11112);
echo $resource->get('pagetitle'); //test I have the resource
$data = $resource->getOne('ResourceData');
The errors I get are:
Could not getOne: foreign key definition for alias ResourceData not
found. No foreign key definition for parentClass: modDocument using
relation alias: ResourceData
The table exists & has data, the package is registered in the modx extension packages. I've been over the schema many times & it looks right.
What is causing these errors?
You have to use the right object class in $modx->getObject. Otherwise you will get a modResource object, that does not know the extended object data and relationship.
$resource = $modx->getObject('extResource', 11112);
Does the resource you are loading have its class_key field set to extResource? That's needed for it to load the right resource object class.
I fail stripping whitespaces inside of inline elements in FOP with DITA-OT PDF2. This is my code snippet:
<p>1 BEFORE <uicontrol>test</uicontrol> AFTER</p>
<p>2 BEFORE <uicontrol> test</uicontrol> AFTER</p>
<p>3 BEFORE <uicontrol>test </uicontrol> AFTER</p>
<p>4 BEFORE <uicontrol><keyword keyref="test"/> </uicontrol> AFTER</p>
<p>5 BEFORE <uicontrol> <keyword keyref="test"/></uicontrol> AFTER</p>
<p>6 BEFORE <uicontrol>
<keyword keyref="test"/>
</uicontrol> AFTER</p>
<p>7 BEFORE <uicontrol>
<keyword keyref="test"/>
</uicontrol> AFTER</p>
Renders to:
This is my attribute set:
<xsl:attribute-set name="uicontrol">
<xsl:attribute name="white-space">nowrap</xsl:attribute>
<xsl:attribute name="white-space-treatment">ignore</xsl:attribute>
<xsl:attribute name="white-space-collapse">true</xsl:attribute>
<xsl:attribute name="linefeed-treatment">treat-as-zero-width-space</xsl:attribute>
<xsl:attribute name="background-color">#ff0000</xsl:attribute>
</xsl:attribute-set>
All red whitespaces have to be stripped. Where is my mistake?
FOP seems to have difficulty in "white-space-treatment":
XSL-FO Property Support Table (ยง7)
So it may be needed to use <xsl:strip-space elements="uicontrol"> plus normalize-space() function for text() in uicontrol.
Following is the result when specifying <xsl:strip-space elements="uicontrol">
For your reference, Antenna House renders your original style definition as follows:
Hope this helps your development.
i create a xml document with JAXP and search a way to insert the schemalocation.
At the moment my application produces:
<?xml version="1.0" encoding="UTF-8"?>
<root>
...
</root>
But i need:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="namespaceURL"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="namespaceURL pathToMySchema.xsd">
...
</root>
My code:
StreamResult result = new StreamResult(writer);
Document doc = getDocument();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.METHOD, "xml");
trans.setOutputProperty(OutputKeys.VERSION, "1.0");
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
DOMSource source = new DOMSource(depl.getAsElement(doc));
trans.transform(source, result);
Thanks for your time,
Kasten
In XML data model namespace nodes are not actually read from parent element but each element has its own namespace nodes. Therefore simply adding a new default namespace to root element doesn't work but results in a document like this
<root xmlns="namespaceURL">
<child xmlns=""/>
...
</root>
Notice the appearing of empty default namespace xmlns="" on the child element(s). What actually needs to be done is to modify the namespace of every node or to create a new document with the desired default namespace and copy the contents, element and attribute names etc. of the old document to the new one. These can be done by recursively going through the original document. With Java DOM implementation this can be laborious, I've heard. One short cut might be to read the document with a namespace-unaware DOM and then add as attribute the new default namespace. Other solution is to change the namespace with an XSLT transformation, which seems quite suitable in this case, since you actually are already generating the output via XSLT transformation.
Use this XSLT stylesheet to add a new default namespace and the schema location to the root element. This stylesheet preserves old namespaces but adds all elements to new default namespace if they previously were in no-namespace.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Template to add a default namespace to a document -->
<!-- Elements without a namespace are "moved" to default namespace -->
<!-- Elements with a namespace are copied as such -->
<!-- string for default namespace uri and schema location -->
<xsl:variable name="ns" select="'namespaceURL'"/>
<xsl:variable name="schemaLoc" select="'namespaceURL pathToMySchema.xsd'"/>
<!-- template for root element -->
<!-- adds default namespace and schema location -->
<xsl:template match="/*" priority="1">
<xsl:element name="{local-name()}" namespace="{$ns}">
<xsl:attribute name="xsi:schemaLocation"
namespace="http://www.w3.org/2001/XMLSchema-instance">
<xsl:value-of select="$schemaLoc"/>
</xsl:attribute>
<xsl:apply-templates select="#* | node()"/>
</xsl:element>
</xsl:template>
<!--template for elements without a namespace -->
<xsl:template match="*[namespace-uri() = '']">
<xsl:element name="{local-name()}" namespace="{$ns}">
<xsl:apply-templates select="#* | node()"/>
</xsl:element>
</xsl:template>
<!--template for elements with a namespace -->
<xsl:template match="*[not(namespace-uri() = '')]">
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:template>
<!--template to copy attributes, text, PIs and comments -->
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Instead of creating the transformer with
Transformer trans = transfac.newTransformer();
(which creates and stylesheet that does an identy transformation), create an XSLT input source and give it as a parameter to newTransformer()
javax.xml.transform.Source xsltSource = new javax.xml.transform.stream.StreamSource(xsltFile);
Transformer trans = transFact.newTransformer(xsltSource);
where xsltFile is a File object pointing to that XSLT file.
Set the output properties as you wish and call transform() as in your sample code. The result should be what you desired, but I have not tested this in Java. The given XSLT file is tested for some trivial cases and there is a sample input and output at the end of this answer.
Some minor notes:
The original document object is not modified in this process. The new default namespace only appears in the output of the transform() method.
The namespace prefix for schema-instance namespace is usually xsi:, not xs: as in your example code (xs: is used in schema definitions (as well as xsd:)) .
Sample input and output for the XSLT stylesheet shown above
Input:
<root>
<child>text</child>
<child attribute="attr-value"/>
<?pi-target pi-content?>
<nsx:ns-child xmlns:nsx="ns1x">
<no-ns-child>text</no-ns-child>
<!-- comment -->
<nsx:ns-child nsx:ns-attribute="nsx-attr-value">text</nsx:ns-child>
</nsx:ns-child>
<defns-child xmlns="default-ns">
<def-child attr="val">text</def-child>
<child xmlns=""/>
</defns-child>
<child>text</child>
</root>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="namespaceURL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="namespaceURL pathToMySchema.xsd">
<child>text</child>
<child attribute="attr-value"/>
<?pi-target pi-content?>
<nsx:ns-child xmlns:nsx="ns1x">
<no-ns-child>text</no-ns-child>
<!-- comment -->
<nsx:ns-child nsx:ns-attribute="nsx-attr-value">text</nsx:ns-child>
</nsx:ns-child>
<defns-child xmlns="default-ns">
<def-child attr="val">text</def-child>
<child xmlns="namespaceURL"/>
</defns-child>
<child>text</child>
</root>
You can add the namespaces in the root when creating the document.
String NS_URL = "namespaceURL";
doc = builder.newDocument();
Element root = doc.createElementNS(NS_URL, "root");
root.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance",
"xs:schemaLocation", NS_URL + " pathToMySchema.xsd");
doc.appendChild(root);
Then for each element added to the doc instead of createElement() use createElementNS()
doc.createElementNS(NS_URL, name);
This results in what you were looking for.
<root
xmlns="namespaceURL"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="namespaceURL pathToMySchema.xsd"
>
Here's how to give a hint to the parser in order to solve your problem:
http://bytes.com/topic/java/answers/16892-xerces-how-perfrom-schema-validations-without-using-xsi-schemalocation
It goes like this:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLocation",
"http://www.example.com/Report.xsd");
Here is a validation example with some source code. It might help you.
http://www.ibm.com/developerworks/xml/library/x-tipvalschm/
(If all comes to worse, you can always search-and-replace. I know it is not the ideal solution, but the javax.xml.transform.OutputKeys doesn't seem to have a member related to the schemalocation attribute.)