I need to export both simple geometry and a vector field to some VTK files. I have managed to export the geometry, but am struggeling to figure out how to export the vector field. What is the structure/format of the file I need?
This is what I have so far (by the way, the vectors need to be arbitrarily placed, meaning that strucured grid and so on won't work):
<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian">
<PolyData>
<Piece NumberOfPoints="8" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="5">
<Points>
<DataArray type="Float32" NumberOfComponents="3" format="ascii">
//point data//
</DataArray>
</Points>
<Polys>
<DataArray type="Int32" Name="connectivity" format="ascii">
//connectivity data//
</DataArray>
<DataArray type="Int32" Name="offsets" format="ascii">
//offsett data//
</DataArray>
</Polys>
</Piece>
//Need to put vector field with it's own points here//
</PolyData>
</VTKFile>
Update: After suggestions from Chris (see answer below) I have updated the file to this form:
<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
<UnstructuredGrid>
<Piece NumberOfPoints="50" NumberOfCells="0">
<PointData Vectors="Velocity">
<DataArray Vectors="Velocity">
//vector data//
</DataArray>
</PointData>
<Points>
<DataArray type="Float32" NumberOfComponents="3" format="ascii">
//point data//
</DataArray>
</Points>
<Cells/>
<CellData/>
</Piece>
</UnstructuredGrid>
</VTKFile>
From you example XML file it seems that the vector field is defined at different coordinates from the nodes of your PolyData. If this is the case then you will need to use two different files. From the VTK File Format specification, which is part of the VTK User's Guide (see www.vtk.org/VTK/img/file-formats.pdf):
By convention, each data type and file type is paired with a particular file extension.
Your vector field sounds like UnstructuredGrid data, where you have to specify the coordinates of the grid nodes explicitly (unlike, say ImageGrids, where the node coordinates are defined implicitly by the spacing and the extent of the data). This obviously cannot go in a PolyData VTK file (see the second line of your example XML file).
So try writing a new file for your vector data with the outline (taken from the file formats document):
<VTKFile type="UnstructuredGrid" ...>
<UnstructuredGrid>
<Piece NumberOfPoints="#" NumberOfCells="0">
<Points>
<DataArray type="Float32" NumberOfComponents="3" format="ascii">
//point data//
</DataArray>
</Points>
<Cells>
<DataArray type="Int32" Name="connectivity" .../>
<DataArray type="Int32" Name="offsets" .../>
<DataArray type="UInt8" Name="types" .../>
</Cells>
<PointData>
<DataArray Vectors="MyVector">
//Vector data goes here//
</DataArray>
</PointData>
<CellData/>
</Piece>
</UnstructuredGrid>
</VTKFile>
Update: As discussed in the comments, the Cells element must be specified (the CellData element can be left empty, as only point data is being speicifed). The Cells element specifies the cell types, connectivity and offsets. For a series of unconnected points (i.e. particles) this information is specified as arrays of length n, where n is the number of data points and where
type = 1, 1, .... 1
connectivity = 0, 1, 2, ... n
offsets = 1, 2, 3, ... n
Related
I would like to do a responsive design for my page, with high resolution, it would be :
And for lower resolution, it would be :
But I have this for high resolution (we can see all the space between the filters and the listview) :
I have this for a low resolution (the search bar has disapeared, and a very large space between my filters) :
Herebelow my code :
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:entities="clr-namespace:XXX"
xmlns:services="clr-namespace:XXXX"
x:Class="Exxxxx"
Title="Test">
<ContentPage.Resources>
<ResourceDictionary>
<toolkit:EnumToIntConverter x:Key="EnumToIntConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<FlexLayout Direction="Row" Wrap="Wrap" Margin="30">
<ContentView>
<FlexLayout Direction="Row" Wrap="Wrap">
<Picker Title="Duration" Margin ="0, 0, 30, 0" WidthRequest="150" ItemsSource="{Binding AllDurations}" SelectedIndex="{Binding SelectedDuration, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type services:EFilterDuration}}"/>
<Picker Title="Zone" Margin ="0, 0, 30, 0" WidthRequest="150" ItemsSource="{Binding AllZones}" SelectedIndex="{Binding SelectedZone, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type entities:EZone}} " />
<SearchBar WidthRequest="250" Placeholder="Search tests..." SearchCommand="{Binding SearchCommand}" VerticalOptions="Start" HorizontalOptions="End" FlexLayout.Grow="1"/>
</FlexLayout>
</ContentView>
<ListView ItemsSource="{Binding Workouts}" HorizontalOptions="Fill" Margin="0, 20, 0 ,0" FlexLayout.Grow="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<FlexLayout
Wrap="Wrap"
HorizontalOptions="Fill"
HeightRequest="80"
Margin="5, 0, 5, 10"
BackgroundColor="White">
<VerticalStackLayout Margin="10, 0, 0, 0">
<Label Text="Test"/>
</VerticalStackLayout>
</FlexLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</FlexLayout>
</ContentPage>
I don't understand what I'm doing wrong.
Thanks in advance.
<FlexLayout Direction="Row" Wrap="Wrap" Margin="30">
You are not aligning, justifying or doing anything here.
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/flexlayout?view=net-maui-7.0
You can change how items are distributed between main and off axis. The default value being "Stretch". This is why you are getting such results.
However, I do not think that this is the best way to handle different layouts, tomorrow, you will want part of this interface to not show at all, because it is not that important. What will you do? Start hiding VisualElements one by one?
using xslt 3, i need to take all content elements' values, and move them to the title elements (if the title elements already exist in a record, they need to be appended with a separator like -) i now have inputted my real data, since the below solution does not solve the problem when implemented to something like:
example input:
<data>
<RECORD ID="31365">
<no>25099</no>
<seq>0</seq>
<date>2/4/2012</date>
<ver>2/4/2012</ver>
<access>021999</access>
<col>GS</col>
<call>889</call>
<pr>0</pr>
<days>0</days>
<stat>0</stat>
<ch>0</ch>
<title>1 title</title>
<content>1 content</content>
<sj>1956</sj>
</RECORD>
<RECORD ID="31366">
<no>25100</no>
<seq>0</seq>
<date>2/4/2012</date>
<ver>2/4/2012</ver>
<access>022004</access>
<col>GS</col>
<call>8764</call>
<pr>0</pr>
<days>0</days>
<stat>0</stat>
<ch>0</ch>
<sj>1956</sj>
<content>1 title</content>
</RECORD>
</data>
expected output:
<data>
<RECORD ID="31365">
<no>25099</no>
<seq>0</seq>
<date>2/4/2012</date>
<ver>2/4/2012</ver>
<access>021999</access>
<col>GS</col>
<call>889</call>
<pr>0</pr>
<days>0</days>
<stat>0</stat>
<ch>0</ch>
<title>1 title - 1 content</title>
<sj>1956</sj>
</RECORD>
<RECORD ID="31366">
<no>25100</no>
<seq>0</seq>
<date>2/4/2012</date>
<ver>2/4/2012</ver>
<access>022004</access>
<col>ΓΣ</col>
<call>8764</call>
<pr>0</pr>
<days>0</days>
<stat>0</stat>
<ch>0</ch>
<sj>1956</sj>
<title>1 title</title>
</RECORD>
<data>
with my attempt, i did not manage to move the elements, i just got an empty line where the content element existed, so please add the removal of blank lines in the suggested solution.
i believe the removal of blank lines could be fixed with the use of
<xsl:template match="text()"/>
One way to achieve this is the following template. It uses XSLT-3.0 content value templates.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" expand-text="true">
<xsl:output method="xml" indent="yes" />
<xsl:mode on-no-match="shallow-copy" />
<xsl:strip-space elements="*" /> <!-- Remove space between elements -->
<xsl:template match="RECORD">
<xsl:copy>
<xsl:copy-of select="#*" />
<title>{title[1]}{if (title[1]) then ' - ' else ''}<xsl:value-of select="content" separator=" " /></title>
<xsl:apply-templates select="node() except (title,content)" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
It's output is as desired.
If you want to separate the <content> elements with a -, too, you can simplify the core <title> expression to
<xsl:value-of select="title|content" separator=" - " />
EDIT:
All I changed was replacing chapter with RECORD, and it's working fine with Saxon-HE 9.9.1.4J. The only difference in the output is that the title element is always at the first position, but that shouldn't matter. I also added a directive to remove space between elements.
What i want to do is similar in the following link but we want it using search:search:
Queries Constrained to Elements
Basically we have 2 xmls like the following:
XML-1
<rootElement>
<id>7635940284725382300</id>
<parentElement>
<childElement1>ce1-A</childElement1>
<childElement2>ce2-1</childElement2>
</parentElement>
<parentElement>
<childElement1>ce1-B</childElement1>
<childElement2>ce2-2</childElement2>
</parentElement>
<parentElement>
<childElement1>ce1-C</childElement1>
<childElement2>ce2-3</childElement2>
</parentElement>
</rootElement>
XML-2
<rootElement>
<id>7635940284725382398</id>
<parentElement>
<childElement1>ce1-A</childElement1>
<childElement2>ce2-2</childElement2>
</parentElement>
<parentElement>
<childElement1>ce1-B</childElement1>
<childElement2>ce2-3</childElement2>
</parentElement>
<parentElement>
<childElement1>ce1-C</childElement1>
<childElement2>ce2-4</childElement2>
</parentElement>
</rootElement>
So now what i want to do is to have a match for childElement1 and childElement2 within the same parentElement.
For example:
If i search with values childElement1 = ce1-B and childElement2 = ce2-3, it should only give me XML-2 and not return XML-1.
We have achieved this using the cts:search query as explained in the link:
cts:search (/,
cts:element-query (
xs:QName ('parentElement'),
cts:and-query ((
cts:element-value-query(xs:QName('childElement1'), 'ce1-B', 'exact'),
cts:element-value-query(xs:QName('childElement2'), 'ce2-3', 'exact')
))
)
)
Question:
We are using search:search with different search:constraints? I have read about using container for this but there are no good examples to show how it can be used.
Here is our sample search:search, so need to tweak this to have the same functionality as that shown by cts:search query shown above:
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
search:search("childElement1:ce1-B AND childElement2:ce2-3 sort:childElement2ASC"
, <options xmlns="http://marklogic.com/appservices/search">
<term>
<term-option xmlns="http://marklogic.com/appservices/search">unstemmed</term-option>
<empty apply="all-results" />
<term-option>case-insensitive</term-option>
<term-option>wildcarded</term-option>
</term>
<transform-results apply="transformed-result" ns="http://isearchgui/search" at="/customResultSet.xqy" />
<search:constraint name="childElement1">
<search:range type="xs:string" facet="false" collation="http://marklogic.com/collation/en">
<search:path-index ns="http://my.search.com/something">//childElement1</search:path-index>
</search:range>
</search:constraint>
<search:constraint name="childElement2">
<search:range type="xs:string" facet="false" collation="http://marklogic.com/collation/en">
<search:path-index ns="http://my.search.com/something">//childElement2</search:path-index>
</search:range>
</search:constraint>
<search:operator name="sort">
<search:state name="childElement1ASC">
<search:sort-order direction="ascending" type="xs:string">
<search:path-index ns="http://my.search.com/something">//childElement1</search:path-index>
</search:sort-order>
</search:state>
<search:state name="childElement1DES">
<search:sort-order direction="descending" type="xs:string">
<search:path-index ns="http://my.search.com/something">//childElement1</search:path-index>
</search:sort-order>
</search:state>
<search:state name="childElement2ASC">
<search:sort-order direction="ascending" type="xs:string">
<search:path-index ns="http://my.search.com/something">//childElement2</search:path-index>
</search:sort-order>
</search:state>
<search:state name="childElement2DES">
<search:sort-order direction="descending" type="xs:string">
<search:path-index ns="http://my.search.com/something">//childElement2</search:path-index>
</search:sort-order>
</search:state>
</search:operator>
</options>
, 0
, 15);
Hope this helps to answer.
You are on the right track. Use the container option, which works like any other constraint option, then wrap your nested query in parenthesis.
For example:
search:parse('contain:(test one two)',
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="contain">
<container>
<element ns="" name="parentElement"/>
</container>
</constraint>
</options>)
=>
<cts:element-query xmlns:cts="http://marklogic.com/cts">
<cts:element>parentElement</cts:element>
<cts:and-query>
<cts:word-query>
<cts:text xml:lang="en">test</cts:text>
</cts:word-query>
<cts:word-query>
<cts:text xml:lang="en">one</cts:text>
</cts:word-query>
<cts:word-query>
<cts:text xml:lang="en">two</cts:text>
</cts:word-query>
</cts:and-query>
</cts:element-query>
So in your case you would have the main-search string as :
search:search('contain:(childElement1:ce1-B AND childElement2:ce2-3) sort:childElement2ASC', <options ....)
Given the following XML element structure:
<a>
<b>
<c test_id="1"/>
<d test_ref="1"/>
</b>
<e>
<c test_id="12"/>
</e>
<a>
and the following XSD rules:
-) in Element a:
<xsd:key name="key_A">
<xsd:selector xpath=".//c"/>
<xsd:field xpath="#test_id"/>
</xsd:key>
<xsd:keyref name="keyref_A" refer="key_A"">
<xsd:selector xpath=".//d"/>
<xsd:field xpath="test_id"/>
</xsd:keyref>
-) in Element b:
<xsd:key name="key_B">
<xsd:selector xpath=".//c"/>
<xsd:field xpath="#test_id"/>
</xsd:key>
<xsd:keyref name="keyref_B" refer="key_B"">
<xsd:selector xpath=".//d"/>
<xsd:field xpath="test_id"/>
</xsd:keyref>
When I set test_ref to "12" I get a validation error.
When I set test_ref to "1" I get no error.
How are multiple keys/keyrefs interpreted? Does every keyref needs to be valid? Do I get not error when I set it to "1" because it satisfies both keys?
There are already questions regarding this topic but none explains how it is evaluated by a parser.
I am using Pentaho Data Integration, I created a new transformation and I have 2 steps in it....1 is a CSV file of my data, the second is an Excel file with two columns one is are the state names and the other the sort form of that state name, Example ("New York" "NY")
In my CSV file I have a state columns with the state names "New York" I want to use my excel file to map "New York" with "NY"
I have googled this all day with no clear answer...can anyone help?
You can use Merge Join. Using this you can merge both the files and select the desired columns. Before merging, you have to sort those files according to fields which use are using for mapping. In your case, it will be state name.
I would recommend you to use stream lookup to do this task. Check the test transformation attached. It will do your task.
<?xml version="1.0" encoding="UTF-8"?>
<transformation-steps>
<steps>
<step>
<name>EXCEL</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>State</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
<field>
<name>Short_state</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<data>
<line> <item>New York</item><item>TX</item> </line>
<line> <item>Texas</item><item>TX</item> </line>
</data>
<cluster_schema/>
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
<xloc>392</xloc>
<yloc>80</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>CSV</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<name>Full_state_name</name>
<type>String</type>
<format/>
<currency/>
<decimal/>
<group/>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
</field>
</fields>
<data>
<line> <item>New York</item> </line>
<line> <item>Texas</item> </line>
</data>
<cluster_schema/>
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
<xloc>511</xloc>
<yloc>169</yloc>
<draw>Y</draw>
</GUI>
</step>
<step>
<name>Stream lookup</name>
<type>StreamLookup</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<from>EXCEL</from>
<input_sorted>N</input_sorted>
<preserve_memory>Y</preserve_memory>
<sorted_list>N</sorted_list>
<integer_pair>N</integer_pair>
<lookup>
<key>
<name>Full_state_name</name>
<field>State</field>
</key>
<value>
<name>State</name>
<rename>State</rename>
<default/>
<type>String</type>
</value>
<value>
<name>Short_state</name>
<rename>Short_state</rename>
<default/>
<type>String</type>
</value>
</lookup>
<cluster_schema/>
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
<xloc>510</xloc>
<yloc>79</yloc>
<draw>Y</draw>
</GUI>
</step>
</steps>
<order>
<hop> <from>EXCEL</from><to>Stream lookup</to><enabled>Y</enabled> </hop>
<hop> <from>CSV</from><to>Stream lookup</to><enabled>Y</enabled> </hop>
</order>
<notepads>
</notepads>
<step_error_handling>
</step_error_handling>
</transformation-steps>