Currently we have a set of related xml files(4 files) to represent a single entity.
One xml file may refer to an element in another xml file. How can we write the XSD for validating this scenario?
EG:
XMLFile1:
<Actors>
<Actor id="A1">
<Name>Name1</Name>
<Movies>
<Movie Id="M1" />
<Movie Id="M2" />
</Movies>
</Actor>
<Actor id="A2">
<Name>Name2</Name>
<Movies>
<Movie Id="M2" />
<Movie Id="M3" />
</Movies>
</Actor>
</Actors>
XMLFile2:
<Movies>
<Movie Id="M1">
<Name>Name1</Name>
</Movie>
<Movie Id="M2">
<Name>Movie2</Name>
</Movie>
</Movies>
Now in the two examples, Actor id="A2" refers to movie Movie id="M3" which doesn't exist.
how do we validate the cross references between the two files?
You need, with some external process (xpath, xslt...) collect the movies ids from xmlfile1, and generate an xml schema with an enum type (for instance) wich test ids in xmlfile2.
Related
I'm trying to leverage Import/Export module to import taxonomies and taxonomy terms like so
<Orchard>
<Data>
<Taxonomy Id="/Identifier=Product-Categories" Status="Published">
<AutoroutePart Alias="eshop/categories" UseCustomPattern="false" />
<IdentityPart Identifier="Product-Categories" />
<TitlePart Title="Product Categories" />
<TaxonomyPart TermTypeName="ProductCategoriesTerm" />
</Taxonomy>
<ProductCategoriesTerm Id="/Identifier=Category-1" Status="Published">
<AutoroutePart UseCustomPattern="false" />
<IdentityPart Identifier="Category-1" />
<TitlePart Title="Test category" />
<TermPart Count="0" Selectable="true" Weight="1" TaxonomyId="/Identifier=Product-Categories" Path="" />
</ProductCategoriesTerm>
</Data>
</Orchard>
ProductCategoriesTerm when created through dashboard has default pattern
{Content.Container.Path}/{Content.Slug} ### my-taxonomy/my-term/sub-term
but importing terms makes them to use just {Content.Slug} ... How do I instruct AutoroutePart to use the default pattern? Tried UseCustomPattern="false" or exclude AutoroutePart with no effect it's just test-category instead of eshop/categories/test-category and won't regenerate even if if I set AutouroutePart to automatically regenerate when editing content and disable custom patterns and it won't revert to default pattern even if I try to publish it through dashboard.
Also it's mandatory to include "Count" for the TermPart when importing, does it affect anything? Sounds like something that should be dynamic and relevant only with export.
When importing taxonomy terms (and I guess any other part that has a container) it's necessary to specify Container for the common part. Without it Container for the part is null and therefore can't resolve {Content.Container.Path} in the alias pattern.
<CommonPart Container="/Identifier=Product-Categories" />
Or if it's nested term then Container is the parent term.
I am developing a class where I wish to databind the attributes of a class to a dataset.
I have managed to get the following to work in the following simplified version of my class:
<class name="myclass">
<dataset name="attSettings"><settings>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</settings></dataset>
<attribute name="default_applyshadow" type="boolean" value="$once{(this.attSettings.getPointer()).xpathQuery('settings/property[#name="applyshadow"]/#defaultvalue')}" />
</class>
However, this syntax is very cumbersome and does not feel right so I am wondering if there is a better way to do this.
This doesn't answer your question but explains why you cannot use a local dataset in your situation. When you have a local dataset in a class, the dataset can only be addressed in children of the class, e.g.:
<canvas debug="true">
<class name="myclass">
<dataset name="myds">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot.myds:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
<myclass />
</canvas>
The <text> element can access the dataset of the parent class by prepending local: to the datapath value. If you don't select a name for your dataset, OpenLaszlo will automatically use the name localdata for the dataset. Datasets using that name can be addressed by omitting the dataset name in the datapath/xpath value, e.g.
<class name="myclass">
<dataset>
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
Note that the datapath does not have a name and that the datapath used for the <text> component is now local:classroot:/root/..., while local:classroot.localdata:/root/... would work as well.
I don't understand the design decision which makes it impossible to allow the use a local dataset in the datapath of a class containing that dataset, but maybe there were some technical reasons (initialization order, etc.) for it.
I figured out the proper syntax to do what I wanted:
<dataset name="myclass_settings">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<class name="myclass" datapath="myclass_settings:/root">
<attribute name="default_applyshadow" type="boolean" value=$path{'property[#name="applyshadow"]/#defaultvalue'}" />
</class>
The $path{} constraint is used on the class attribute to link the value to the dataset via a relative xpath query. I also had to move the dataset outside of the class to get it to work.
Is there any way to have a custom recipe add some text and image fields to the page? It looks like part of the recipe handles commands, but I can't find any commands that do this at # http://docs.orchardproject.net/Documentation/Using-the-command-line-interface
Update
Thanks for the response Bertrand, but there are some issues with that.
I exported everything for a recipe from a tenant that has 1. added fields, 2. added parts to the Page along with 3. an added List and 4. an added container widget to the Default layer that shows the list.
<Metadata>
<Types>
<Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true">
<TagsPart />
<LocalizationPart />
<TitlePart/>
<AutoroutePart />
<ContainablePart />
<AmazonProductsPart />
<YouTubeVideosPart />
</Page>
</Types>
<Parts>
<BodyPart BodyPartSettings.FlavorDefault="html" />
<Page ContentPartSettings.Attachable="True">
<Thumbnail.ImageField DisplayName="Thumbnail" ImageFieldSettings.MaxHeight="75" ImageFieldSettings.MaxWidth="75" ImageFieldSettings.Required="False" ImageFieldSettings.AlternateText="True" ImageFieldSettings.ResizeAction="Validate" />
<PageImage.ImageField DisplayName="PageImage" ImageFieldSettings.MaxHeight="250" ImageFieldSettings.MaxWidth="0" ImageFieldSettings.Required="False" ImageFieldSettings.AlternateText="True" ImageFieldSettings.ResizeAction="Resize" />
<PreContent.TextField DisplayName="PreContent" ImageFieldSettings.MaxHeight="0" ImageFieldSettings.MaxWidth="0" ImageFieldSettings.Required="False" ImageFieldSettings.AlternateText="False" ImageFieldSettings.ResizeAction="Validate" TextFieldSettings.Flavor="Html" TextFieldSettings.Required="False" />
<PostContent.TextField DisplayName="PostContent" ImageFieldSettings.MaxHeight="0" ImageFieldSettings.MaxWidth="0" ImageFieldSettings.Required="False" ImageFieldSettings.AlternateText="False" ImageFieldSettings.ResizeAction="Validate" TextFieldSettings.Flavor="Html" TextFieldSettings.Required="False" />
</Page>
</Parts>
</Metadata>
...
<Data>
<List Id="/alias=page-list" Status="Published">
<CommonPart Owner="/User.UserName=admin" CreatedUtc="2012-05-26T22:52:20Z" PublishedUtc="2012-05-26T22:57:37Z" ModifiedUtc="2012-05-26T22:57:37Z" />
<AutoroutePart Alias="page-list" UseCustomPattern="false" />
<AdminMenuPart AdminMenuPosition="2" OnAdminMenu="false" />
<MenuPart MenuText="Page List" MenuPosition="3" OnMainMenu="false" />
<ContainerPart ItemContentType="Page" ItemsShown="true" Paginated="true" PageSize="10" OrderByProperty="CommonPart.CreatedUtc" OrderByDirection="1" />
<TitlePart Title="Page List" />
</List>
<ContainerWidget Id="" Status="Published">
<CommonPart Owner="/User.UserName=admin" Container="/Layer.LayerName=Default" CreatedUtc="2012-05-26T22:55:42Z" PublishedUtc="2012-05-26T22:55:42Z" ModifiedUtc="2012-05-26T22:55:42Z" />
<WidgetPart Title="Page List" Position="1" Zone="AsideFirst" RenderTitle="false" />
<ContainerWidgetPart Container="/alias=page-list" PageSize="5" OrderByProperty="CommonPart.CreatedUtc" OrderByDirection="1" ApplyFilter="false" FilterByProperty="CustomPropertiesPart.CustomOne" FilterByOperator="=" />
</ContainerWidget>
</Data>
I then inject that into a copy of the default recipe with the appropriate modules activated.
When creating a new tenant from that recipe,
All the modules are enabled, good
The list is created, good
The page has the added parts, good
The page does not have the added fields, bad
The container widget does not exist, bad
It looks like the part fields are not added, and the widget was not created.
I did another simple test, and it looks like a bug?
Repro Steps:
Add fields to the page
Add a widget
Export everything
delete the widget
Import the exported xml
Expected: The widget to be back
Actual: the widget is still missing
is the recipe suppose to honor page fields and widgets, did I do something wrong, or is this a bug?
Update
Okay, this has to be a bug. When manually adding the fields, I get this message even though it isn't showing the fields: "A field with the same name already exists."
You don't need a command, this is supported by recipes without that. The easiest way to get an example is to add a field from the admin UI, and then export the metadata and examine the recipe that created.
My XML file looks something like this:
<Fields>
<Humanities>
<Performing_Arts>
<Dance />
<Music />
</Performing_Arts>
<Visual_Arts>
<Painting />
<Sculptue />
</Visual_Arts>
</Humanities>
<Social_Sciences>
<Psychology>
<Cultural_Psychology />
<Social_Psychology />
</Psychology>
</Social_Sciences>
</Fields>
I want to write an XML Schema, for this file, so that no two nodes, irrespective of location in the file can have duplicate names.
Any node in this file should be allowed to have unlimited child nodes, to any sub-level.
How might I achieve this goal?
skaffman is quite right, you needto enclose your values as either attributes or elements, if you are unsure, w3 schools hasa great tutorial on this;
http://www.w3schools.com/xml/xml_elements.asp
http://www.w3schools.com/xml/xml_attributes.asp
An example of a possible xml representation of your data might be:
<fields>
<department name="Humanities">
<subject name="Peforming Arts">
<topic name="Dance"/>
<topic name="Music"/>
</subject>
<subject name="Visual Arts">
<topic name="Painting"/>
<topic name="Sculpture"/>
</subject>
</department>
<department name="Social Sciences">
<subject name="Psychology">
<topic name="Cultural Psychology"/>
<topic name="Social Psychology"/>
</subject>
</department>
</fields>
Notes:
You can see that this is roughly equivalent to a database with three tables: department, subject and topic, with FK relationships between the parent and children. This is really what XML encapsulates, but in text form, and is the sort of thing to bear in mind while you design your layout.
I've used all lower-case names for elements and attributes. This is a personal thing as xsl/xpath as case sensitive, so making everything lowercase avoids the opporyunity for horrid bugs later
Info: C# , VS2010 Beta 2 , DSL ToolKit Beta 2
I am trying to create the following generated XML in my DSL Diagram when used
<Method>
...
<FilterDescriptors>
<FilterDescriptor Type="Comparison" Name="EmployeeKey" />
</FilterDescriptors>
...
</Method>
This is how the Method and Filter Descriptor Domain Classes look
I believe I have set the multiplicity correct:
Method should only have 1 Filter Descriptor
A Filter Descriptor can have many Filter Descriptors i.e
<FilterDescriptors>
<FilterDescriptor Type="Comparison" Name="EmployeeKey" />
<FilterDescriptor Type="Wildcard" Name="EmployeeName" />
</FilterDescriptors>
The issue is that the output XML is like this:
<FilterDescriptors>
<FilterDescriptor>
<FilterDescriptors>
<FilterDescriptor Type="Comparison" Name="EmployeeKey" />
</FilterDescriptors>
</FilterDescriptor>
</FilterDescriptors>
We have this same pattern is several locations in our DSL Diagram and was hoping there is a something simple to resolve this rather than overriding the ReadElements and WriteElements of each domain class
Have you posted this in the DSL Tools forum at http://social.msdn.microsoft.com/Forums/en-US/dslvsarchx/threads? I don't see a thread there for it.