Is it possible to control the order of the attribute values in Relax NG? which can be achieved using xs:assert in schema?
XML:
<body>
<h1 class="title">title</h1>
<h2 class="subtitle">subtitle</h2>
<p class="paragraph1">para text 1</p>
<p class="paragraph2">Para text 2</p>
<p class="paragraph3">Para text 2</p>
</body>
The class value should be in order, paragraph1 should always come first and paragraph2 should come after paragraph1. The assert I tried in schema:
<xs:assert test="p[1]/#class = 'paragraph1'
and ((every $i in p[2] satisfies $i/#class = 'paragraph2')
and (every $i in p[3] satisfies $i/#class = 'paragraph3')) "/>
A (compact-syntax) RelaxNG grammar to express what the question describes could be written as:
start = element body { h1?, h2?, p.paragraph1?, p.paragraph2?, p.paragraph3? }
h1 = element h1 { text & attribute class { string } }
h2 = element h2 { text & attribute class { string } }
p.paragraph1 = element p { text & attribute class { string "paragraph1" } }
p.paragraph2 = element p { text & attribute class { string "paragraph2" } }
p.paragraph3 = element p { text & attribute class { string "paragraph3" } }
Expressed in the RelaxNG XML syntax:
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
<start>
<element name="body">
<optional>
<ref name="h1"/>
</optional>
<optional>
<ref name="h2"/>
</optional>
<optional>
<ref name="p.paragraph1"/>
</optional>
<optional>
<ref name="p.paragraph2"/>
</optional>
<optional>
<ref name="p.paragraph3"/>
</optional>
</element>
</start>
<define name="h1">
<element name="h1">
<interleave>
<text/>
<attribute name="class">
<data type="string"/>
</attribute>
</interleave>
</element>
</define>
<define name="h2">
<element name="h2">
<interleave>
<text/>
<attribute name="class">
<data type="string"/>
</attribute>
</interleave>
</element>
</define>
<define name="p.paragraph1">
<element name="p">
<interleave>
<text/>
<attribute name="class">
<value type="string">paragraph1</value>
</attribute>
</interleave>
</element>
</define>
<define name="p.paragraph2">
<element name="p">
<interleave>
<text/>
<attribute name="class">
<value type="string">paragraph2</value>
</attribute>
</interleave>
</element>
</define>
<define name="p.paragraph3">
<element name="p">
<interleave>
<text/>
<attribute name="class">
<value type="string">paragraph3</value>
</attribute>
</interleave>
</element>
</define>
</grammar>
Related
I have created a custom product restriction for a component due to project specific visibility rules. This product restriction can be applied on ExampleListComponent, ExampleComponent and also can be used in homepage, product page or content pages as and when required. ExampleListComponent can have multiple ExampleComponent instances. When apply the restriction on ExampleListComponent(which is added directly on homepage content slot) it is working fine but when apply the same on ExampleComponent(child component) it is not working. Following are some code snippets
items.xml
<collectiontype code="ExampleCardList" elementtype="ExampleComponent" autocreate="true" generate="true" type="list" />
<itemtype code="ExampleComponent" extends="AbstractMediaContainerComponent" autocreate="true" generate="true" jaloclass="com.example.core.jalo.ExampleComponent">
<attributes>
<attribute qualifier="title" type="localized:java.lang.String">
<persistence type="property" />
</attribute>
<attribute qualifier="secondaryMedia" type="Media">
<modifiers read="true" write="true" search="true" unique="false" />
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
<itemtype code="ExampleListComponent" extends="SimpleCMSComponent" autocreate="true" generate="true" jaloclass="com.example.core.jalo.ExampleListComponent">
<attributes>
<attribute qualifier="cards" type="ExampleCardList">
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
<itemtype code="ExampleAvailabilityRestriction" jaloclass="com.example.core.jalo.restrictions.ExampleAvailabilityRestriction" extends="AbstractRestriction" autocreate="true" generate="true">
<attributes>
<attribute qualifier="product" type="ProductList">
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
ExampleAvailabilityRestrictionEvaluator.java
public class ExampleAvailabilityRestriction implements CMSRestrictionEvaluator<ExampleAvailabilityRestrictionModel> {
public boolean evaluate(ExampleAvailabilityRestrictionModel restrictionModel, RestrictionData restrictionData) {
List<ProductModel> products = restrictionModel.getProduct();
if (CollectionUtils.isEmpty(products)) {
return true;
}
for (ProductModel product : products) {
if (!availabilityService.isProductAvailable(product.getCode())) {
return false;
}
}
return true;
}
}
I verified the other OTB restriction and code looks ok. Is there any other configurations required to be able to apply the restriction on child components.
This article helped me to resolve the issue.
https://answers.sap.com/questions/13121879/time-restriction-not-working-on-cms-link-component.html
Added the following line in examplecardcomponent.jsp
<c:if test="${ycommerce:evaluateRestrictions(component)}">
</c:if>
also we can add this on the parent component jsp(examplecardlistcomponent.jsp) while iterating the child components
<c:forEach var="exampleCard" items="${exampleCards}" varStatus="loop">
<cms:component component="${exampleCard}" evaluateRestriction="true" />
</c:forEach>
Not able to create tasks for new work order from Anywhere. Please suggest
Able to create a new work order without task
Added a new view for tasks, and trying to add taskId, status, Asset with lookup and Location with lookup.
lookup are not visible in UI. Here is my code
<view id="WorkExecution.NewAdhocWorkOrderInspTaskView" label="Create Inspection Tasks" >
<requiredResources id="WorkExecution.NewAdhocWorkOrderInspTaskView_requiredResources">
<requiredResource id="WorkExecutionAdhocINspTaskView.NewAdhocWorkOrderView_additionalasset" name="additionalasset"/>
</requiredResources>
<container id="WorkExecution.NewAdhocWorkOrderInspTaskView_workOrder_container_0" resource="AdhocWOInspTaskResource" >
<group id="WorkExecution.NewAdhocWorkOrderInspTaskView_group_0">
<groupitem id="WorkExecution.NewAdhocWorkOrderInspTaskView_workOrder_groupitem_4" >
<text editable="true" id="WorkExecution.NewAdhocWorkOrderView_groupitem_WorkExecution0.Asset" label="Asset2" layoutInsertAt="item1"
lookup="WorkExecutionAdhocWOInsptask" lookupAttribute="assetnum" placeHolder="Tap to enter1" resourceAttribute="InspTaskAssetNum" />
</groupitem>
</group>
</container>
</view>
<resource additionalData="true" id="AdhocWO_InsptaskResource" name="AdhocWOInspTaskResource" describedBy="http://jazz.net/ns/ism/asset/smarter_physical_infrastructure#WoActivity" providedBy="/oslc/sp/SmarterPhysicalInfrastructure" >
<attributes id="AdhocWO_InsptaskResource_attributes">
<attribute describedByProperty="spi:taskid" id="AdhocWO_InsptaskResource_spi_taskid" name="InspTaskId"/>
<attribute describedByProperty="spi:assetnum" id="AdhocWO_InsptaskResource_spi_AssetNum" name="InspTaskAssetNum"/>
<attribute describedByProperty="spi:location" id="AdhocWO_InsptaskResource_spi_Location" name="InspTaskLocation"/>
<attribute describedByProperty="spi:status" id="AdhocWO_InsptaskResource_spi_Status" name="InspTaskStatus"/>
</attributes>
</resource>
<resource additionalData="true" describedBy="http://open-services.net/ns/asset#Asset" id="additionalasset" name="additionalasset" pageSize="1000" providedBy="/oslc/sp/AssetManagement">
<attributes id="additionalasset_attributes">
<attribute describedByProperty="dcterms:identifier" id="additionalasset_assetuid_dctermsidentifier" name="assetuid"/>
<attribute describedByProperty="spi:assetid" id="additionalasset_assetid_spiassetid" name="assetid"/>
<attribute describedByProperty="spi:orgid" id="additionalasset_orgid_spiorgid" index="true" name="orgid"/>
<attribute describedByProperty="spi:siteid" id="additionalasset_siteid_spisiteid" index="true" isExactMatchIndex="true" name="siteid"/>
<attribute describedByProperty="oslc:shortTitle" id="additionalasset_assetnum_oslcshortTitle" index="true" name="assetnum"/>
</attributes>
<queryBases id="additionalasset_queryBases">
<queryBase id="additionalasset_queryBase_getadditionalasset" name="getadditionalasset" queryUri="/oslc/os/oslcasset"/>
</queryBases>
<whereClause id="additionalasset_whereClause"/>
</resource>
<lookup id="WorkExecutionAdhocWOInsptask" label="Select Asset" resource="additionalasset">
<requiredResources id="WorkExecutionAdhocWO_Insptask.AssetLookup_requiredResources">
<requiredResource id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset" name="additionalasset"/>
<requiredResource id="WorkExecutionAdhocWO_Insptask.AssetLookup_workOrder" name="AdhocWOInspTaskResource"/>
</requiredResources>
<list id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_list" resource="additionalasset">
<listItemTemplate id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_listItemTemplate_Item2Desc2" layout="Item2Desc2">
<listtext cssClass="bold textappearance-medium" id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_Item2Desc2_assetnum" layoutInsertAt="item1" resourceAttribute="assetnum"/>
<listtext cssClass="bold textappearance-medium" id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_Item2Desc2_description" layoutInsertAt="desc1" resourceAttribute="description"/>
<listtext id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_Item2Desc2_location" layoutInsertAt="item2" resourceAttribute="location"/>
<listtext id="WorkExecutionAdhocWO_Insptask.AssetLookup_additionalasset_Item2Desc2_locationdesc" layoutInsertAt="desc2" resourceAttribute="locationdesc"/>
</listItemTemplate>
</list>
<returnAttributes id="WorkExecutionAdhocWO_Insptask.AssetLookup_returnAttributes">
<returnAttribute id="WorkExecutionAdhocWO_Insptask.AssetLookup_assetnum_asset" sourceAttribute="assetnum" targetAttribute="InspTaskAssetNum" />
</returnAttributes>
</lookup>
I am working on an animation. I am using .swf pictures which I rotate with code like below.
My problem is: I want to read the actual rotation angel or position of the view "MoAuxid" when I klick on button "Abfrage". How can I get this result?
Best regards
Main Program:
<Mond width="400" height="400">
<view name="Bedienung_rot" x="800" y="10">
<simplelayout axis="y" inset="8"/>
<text text="Output:"/>
<edittext id="outputID" text = "0"/>
<text text="Arc:"/>
<edittext id="WinkelID" text = "51"/>
<button x="000" y="160">
Rotation
<!-- Handler to execute the Method -->
<handler name="onclick">
var x = WinkelID.getText();
MoAuxid.rotate(x);
outputID.setAttribute('text',x);
</handler>
</button>
<text text="Output2:"/>
<edittext id="output2ID" text = "x"/>
<button x="000" y="160">
Abfrage
<!-- Handler to execute the Method -->
<handler name="onclick">
var x = MoAuxid.getAttribute('y');
output2ID.setAttribute('text',x);
</handler>
</button>
</view>
</Mond>
The Mond4.lzx includes the following code:
<!-- IMAGE RESOURCES -->
<resource name="Mo_Bkgnd" src="images/Kalender.jpg" />
<resource name="Mo_Aux" src="images/Mo_Zeiger_Aux.swf" />
<!-- CLASS: Mond -->
<class name="Mond" resource="Mo_Bkgnd">
<attribute name="stretches" value="both"/>
<attribute name="width" value="${this.unstretchedwidth *.5}"/>
<attribute name="height" value="${this.width}"/>
<attribute name="act_height" value="${this.unstretchedheight}"/>
<attribute name="act_width" value="${this.unstretchedwidth}" />
<attribute name="lasthour" value="00" />
<attribute name="lastminute" value="00" />
<attribute name="timezoneoffset" value="00" />
<attribute name="StdZeigWinkel" value="00" />
<attribute name="TagNachtWinkel" value="00" />
<attribute name="kalZeigWinkel" value="20" />
<attribute name="JahresWinkel" value="00" />
<attribute name="FeiertWinkel" value="00" />
<!-- Aux Zeiger -->
<view name="MoAux" resource="Mo_Aux" x="200" y="201" opacity="1" id="MoAuxid">
<method name="rotate" args="Arc">
var rotincrement = 0 + Arc;
var dur = 0;
this.animate('rotation',rotincrement,dur);
</method>
</view>
</class>
I would like to allow some of my SOAP header elements to be nillable. This is possible for body elements, but I am not sure if it is allowed from header elements.
In the sample message below, I would like to allow the MessageDateTime to be null.
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://mycompany.com/repositoryservice">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://mycompany.com/repositoryservice">
<element name="MessageDateTime" type="dateTime" />
<element name="SaveRequest">
<!-- complexType -->
</element>
</schema>
</types>
<message name="SaveRequest_Headers">
<part name="MessageDateTime" element="tns:MessageDateTime" />
</message>
<message name="SaveRequest">
<part name="parameters" element="tns:SaveRequest" />
</message>
<binding name="RepositoryServiceBinding" type="tns:IRepositoryService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="Save">
<soap:operation soapAction="http://mycompany.com/repositoryservice/Save" style="document" />
<input name="SaveRequest">
<soap:header message="tns:SaveRequest_Headers" part="MessageDateTime" use="literal" />
<soap:body use="literal" />
</input>
</operation>
</binding>
<!-- service, portType -->
</definitions>
It is allowed as long as the definition allows for it. In your case, all you have to do is add the nillable="true" to the element's definition. The result on .NET w/ WCF would look something like this:
[System.ServiceModel.MessageHeaderAttribute(Namespace="...")]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Nullable<System.DateTime> MessageDateTime;
I have what strikes me as a very unusual behavior from Linq for NHibernate.
In general, all my entity classes are working just fine, but one of them throws a "NonUniqueResult" exception from the NHibernate namespace under the following condition.
If I call the following:
getSession<MyClass>().Linq<MyClass>().Count();
it throws the exception. If I call
getSession<MyClass>().Linq<MyClass>().ToList().Count();
it does not.
There's no problem with the other CRUD operations for this class, so I don't think it's my mappings.
My guess is that it has something to do with how the Count() operator ultimately gets materialized as a SQL query, but beyond that I'm not sure where to look.
Updated to include mapping of the class in question
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
<class name="My.App.MyClass, My.App" table="MyClass">
<id name="Id" access="property" column="Id" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid.comb">
</generator>
</id>
<version name="TimeStamp" access="property" column="TimeStamp" type="Int32" />
<property name="CreatedOn" access="property" type="System.DateTime">
<column name="CreatedOn"/>
</property>
<property name="Ticker" access="property" type="Int32">
<column name="Ticker"/>
</property>
<property name="DifferentTicker" access="property" type="Int32">
<column name="DifferentTicker"/>
</property>
<property name="SomeDecimal" access="property" type="System.Decimal">
<column name="SomeDecimal"/>
</property>
<property name="StillAnotherTicker" access="property" type="Int32">
<column name="StillAnotherTicker"/>
</property>
<property name="IsActive" access="property" type="Boolean">
<column name="IsActive"/>
</property>
<many-to-one name="RelatedThing" access="property" class="My.App.RelatedThing, My.App" column="RelatedThingId" lazy="proxy" />
<many-to-one name="OtherRelatedThing" access="property" class="My.App.OtherRelatedThing, My.App" column="OtherRelatedThingId" lazy="proxy" />
<bag name="_schedule" access="property" table="Schedule" lazy="false" cascade="all-delete-orphan">
<key column="MyClassId" />
<one-to-many class="My.App.Schedule, My.App" />
</bag>
<bag name="Vectors" access="property" table="Vectors" lazy="false">
<key column="MyClassId" />
<many-to-many class="My.App.Channels.BaseVector, My.App" column="vectorid"/>
</bag>
</class>
</hibernate-mapping>
Both version work fine for me in a simple unit test. In this example:
using ( var tx = Session.BeginTransaction() )
{
int count = Session.Linq<Customer>().Count();
Assert.Equal( 2, count );
count = Session.Linq<Customer>().ToList().Count();
Assert.Equal( 2, count );
tx.Commit();
}
The first query performs a SQL count:
NHibernate: SELECT count(*) as y0_ FROM "Customer" this_
And the second gets all returns all items into a temporary list and then calls Count() on the list:
NHibernate: SELECT this_.Id as Id9_0_, this_.Name as Name9_0_ FROM "Customer" this_
This leads me to believe that there might be an issue with your mappings. And you really want to get the first one working cause the second won't scale for large datasets.