XML to XML using XSLT3.0 - xslt-3.0

can any one help to solve this, i am trying to convert my xml to json using xslt3.0 function(xml-to-json) its not accepting my xml format, now
I am trying to convert my XML to another format of XML which contains tag name as attribute and value as value and tag name as data type using xslt 3.0 .
input xml:
<widget>
<debug>on</debug>
<window title="Sample Konfabulator Widget">
<name>main_window</name>
<width>500</width>
<height>500</height>
</window>
<image src="Images/Sun.png" name="sun1">
<hOffset>250</hOffset>
<vOffset>250</vOffset>
<alignment>center</alignment>
</image>
<text data="Click Here" size="36" style="bold">
<name>text1</name>
<hOffset>250</hOffset>
<vOffset>100</vOffset>
<alignment>center</alignment>
<onMouseUp>
sun1.opacity = (sun1.opacity / 100) * 90;
</onMouseUp>
</text>
</widget>
output xml:
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<map key="Order">
<map key="InvestmentAccount">
<string key="AccountNumber">10</string>
</map>
<map key="Parcel">
<string key="Limit">0</string>
<string key="ExpiryDate">1900-01-01T00:00:00</string>
<array key="Asset">
<map>
<string key="Open">25.15</string>
<string key="High">25.15</string>
<string key="Low">25.11</string>
<string key="Close">25.87</string>
</map>
<map>
<string key="Open">25.15</string>
<string key="High">25.15</string>
<string key="Low">25.11</string>
<string key="Close">25.87</string>
</map>
</array>
</map>
<string key="OrderDate">2012-10-11T21:46:03.6489906+11:00</string>
</map>
</map>

Related

How to load the following sulu snippet in the twig.html file

I have created the following social media snippet with sulu (headless cms) and now I want to use it in my twig.html file. The only problem is that I don't understand which variables I use to get it running. I have tried a variety of different ways but I just don't understand what variables I need to use so that I can link the social media links correctly. Thanks in advance for the help.
I use sulu as headless cms, and symfony/twig to render it.
This is the Sulu code I have:
<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">
<key>socialmedia</key>
<meta>
<title lang="en">Social Media</title>
<title lang="de">Social Media</title>
</meta>
<properties>
<property name="title" type="text_line" mandatory="true">
<meta>
<title lang="en">Title</title>
<title lang="de">Titel</title>
</meta>
<tag name="sulu.node.name"/>
</property>
<property name="facebookImage" colspan="3" type="single_media_selection">
<meta>
<title lang="en">Facebook Icon</title>
<title lang="de">Facebook Icon</title>
</meta>
</property>
<property name="facebookLink" colspan="9" type="url">
<meta>
<title lang="en">Facebook Link</title>
<title lang="de">Facebook Link</title>
</meta>
<params>
<param name="schemes" type="collection">
<param name="http://"/>
<param name="https://"/>
</param>
</params>
</property>
<property name="instagramImage" colspan="3" type="single_media_selection">
<meta>
<title lang="en">Instagram Icon</title>
<title lang="de">Instagram Icon</title>
</meta>
</property>
<property name="instagramLink" colspan="9" type="url">
<meta>
<title lang="en">Instagram Link</title>
<title lang="de">Instagram Link</title>
</meta>
<params>
<param name="schemes" type="collection">
<param name="http://"/>
<param name="https://"/>
</param>
</params>
</property>
<property name="googleImage" colspan="3" type="single_media_selection">
<meta>
<title lang="en">Google Icon</title>
<title lang="de">Google Icon</title>
</meta>
</property>
<property name="googleLink" colspan="9" type="url">
<meta>
<title lang="en">Google Link</title>
<title lang="de">Google Link</title>
</meta>
<params>
<param name="schemes" type="collection">
<param name="http://"/>
<param name="https://"/>
</param>
</params>
</property>
</properties>
So you can create in your page a snippet_selection or single_snippet_selection to embed a snippet into your page.
If you want to create a snippet which is "global". You can create a snippet area / default snippet.
This means you add a area to your snippet:
<areas>
<area key="settings">
<meta>
<title lang="en">Settings</title>
</meta>
</area>
</areas>
Then you go into the Sulu Admin and create a new snippet. After that you go to your Webspace and select unter "Default Snippets" under the point "Settings" the new snippet.
In your twig you can then load that snippet via the sulu_snippet_load_by_area.html twig function:
{% set snippet = sulu_snippet_load_by_area('settings') %}
{% if snippet %} {# if null content manager did not choice a default snippet in "Default Snippets" Tabs on Webspace #}
{{ dump(snippet) }} {# dump all properties #}
{% endif %}
PS: Try not to create a default/global snippet for every little things. Mostly it is for the "Content Manager" more usable to create 1 "Settings" snippet. Which you have a Section "Social Links" in it instead of having different default snippets.

No stock_available section for newly created product via Prestashop webservices

as the title says, I can successfully create a new Product via Prestashop 1.6.1 webservice. The problem is that the new product XML has an empty stock_available section:
<stock_availables nodeType="stock_available" api="stock_availables" />
so I have no idea how to set the initial quantity for that product. If I set it manually from the back office, the stock_available section is filled.
Maybe there is something I'm missing in the XML request? Here it is:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<product>
<id/>
<id_manufacturer/>
<id_supplier/>
<id_category_default>52</id_category_default>
<new/>
<cache_default_attribute/>
<id_default_image/>
<id_default_combination/>
<id_tax_rules_group/>
<position_in_category/>
<type/>
<id_shop_default/>
<reference>A130</reference>
<supplier_reference/>
<location/>
<width/>
<height/>
<depth/>
<weight/>
<quantity_discount/>
<ean13/>
<upc/>
<cache_is_pack/>
<cache_has_attachments/>
<is_virtual/>
<on_sale/>
<online_only/>
<ecotax/>
<minimal_quantity/>
<price>1.30</price>
<wholesale_price/>
<unity/>
<unit_price_ratio/>
<additional_shipping_cost/>
<customizable/>
<text_fields/>
<uploadable_files/>
<active>1</active>
<redirect_type/>
<id_product_redirected/>
<available_for_order>1</available_for_order>
<available_date/>
<condition/>
<show_price>1</show_price>
<indexed>1</indexed>
<visibility/>
<advanced_stock_management/>
<date_add/>
<date_upd/>
<pack_stock_type/>
<meta_description>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</meta_description>
<meta_keywords>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</meta_keywords>
<meta_title>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</meta_title>
<link_rewrite>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</link_rewrite>
<name>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</name>
<description>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</description>
<description_short>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</description_short>
<available_now>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[product name]]></language>
</available_now>
<available_later>
<language id="1" xlink:href="http://www.mysite.it/prestashop/api/languages/1"><![CDATA[available later]]></language>
</available_later>
<associations>
<categories>
<category>
<id/>
</category>
<category>
<id>52</id>
</category>
</categories>
<images>
<image>
<id/>
</image>
</images>
<combinations>
<combination>
<id/>
</combination>
</combinations>
<product_option_values>
<product_option_value>
<id/>
</product_option_value>
</product_option_values>
<product_features>
<product_feature>
<id/>
<id_feature_value/>
</product_feature>
</product_features>
<tags>
<tag>
<id/>
</tag>
</tags>
<stock_availables>
<stock_available>
<id/>
<id_product_attribute/>
</stock_available>
</stock_availables>
<accessories>
<product>
<id/>
</product>
</accessories>
<product_bundle>
<product>
<id/>
<quantity/>
</product>
</product_bundle>
</associations>
</product>
</prestashop>
Thank you for any help!
Iuri
The problem was probably a bug with that version of Prestashop. With the latest version (1.6.1.17) it works correctly.

Alfresco custom data list layout

I have created a custom data list in Alfresco, and have populated its model with the desired data columns. However, when I view the list in Alfresco share, the order is completely off, and there are elements that I have not defined in the model.
I have searched extensively as to how to fix this, and have not been successful. From what I understand, I need to define the layout in the share-config-custom.xml, which I have attempted below (snippet of only what I added):
<config evaluator="model-type" condition="orpdl:orpList">
<forms>
<form>
<field-visibility>
<show id="orpdl:programName" />
</field-visibility>
<create-form template="../data-lists/forms/dataitem.ftl" />
<appearance>
<field id="orpdl:programName">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
<config evaluator="node-type" condition="orpdl:orpList">
<forms>
<form>
<field-visibility>
<show id="orpdl:programName" />
</field-visibility>
<create-form template="../data-lists/forms/dataitem.ftl" />
<appearance>
<field id="orpdl:programName">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
Content model:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="orpdl:orpDataListModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Information retrieved from the Opportunity Registration Process workflow form.</description>
<author>Alan George</author>
<version>1.0</version>
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="http://www.test.com/model/orpDataListModel/1.0" prefix="orpdl" />
</namespaces>
<constraints>
<constraint name="orpdl:contractTypeList" type="LIST">
<parameter name="allowedValues">
<list>
<value>T&M</value>
<value>FFP</value>
<value>CPFF</value>
<value>CPIF</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<type name="orpdl:orpList">
<title>Opportunity Registration Process</title>
<description>Information retrieved from the Opportunity Registration Process workflow form.</description>
<parent>dl:dataListItem</parent>
<properties>
<property name="orpdl:programName">
<title>Program Name</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="orpdl:programDescription">
<title>Program Description</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="orpdl:client">
<title>Client</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="orpdl:contractType">
<title>Contract Type</title>
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="orpdl:contractTypeList" />
</constraints>
</property>
<property name="orpdl:value">
<title>Value</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
</type>
</types>
</model>
The goal of this code is to have only the programName text box appear. But this is what I'm seeing:
What am I missing?
You are entering wrong condition in <config> tag.
Below
<config evaluator="model-type" condition="orpdl:orpDataListModel">
should replace with
<config evaluator="model-type" condition="orpdl:issuesList">
This will also apply to node-type.

How to remove the specific attribute from XmlDocument

My Xml as below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject>
<addresses>
<address/>
</addresses>
</subject>
</subjects>
</dataset>
</order>
To reorder the xml element and to add namespace i did it as per below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject>
</subject>
</subjects>
<addresses>
<address/>
</addresses>
</dataset>
</order>
I did using below code
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlClueReqToLexisNexis.NameTable);
nsmgr.AddNamespace("ab", "http://example.com/abc");
XmlNode order = xmlClueReqToLexisNexis.SelectSingleNode("//ab:order", nsmgr);
XmlNode dataset = xmlClueReqToLexisNexis.SelectSingleNode("//ab:order//ab:dataset", nsmgr);
var subjects = order.SelectSingleNode("//ab:order//ab:dataset//ab:subjects", nsmgr);
I am able to reorder and add namespace to it but it left behind xmlns attribute
as below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject xmlns="">
</subject>
</subjects>
<addresses xmlns="">
<address/>
</addresses>
</dataset>
</order>
I want to remove only attribute xmlns="" out of addresses and subject
Please suggest me the best way to do that.

Is it possible to add a separator in a javafx choicebox in FXML?

This document describes how to add a separator to a javafx 2 choicebox by code:
http://docs.oracle.com/javafx/2/ui_controls/choice-box.htm
I would like to achieve the same using a FXML layout. Any ideas?
.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.HBox?>
<?import java.lang.*?>
<HBox xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
<ChoiceBox>
<String fx:value="Item 1" />
<String fx:value="Item 2" />
<Separator />
<String fx:value="Item 3" />
</ChoiceBox>
</HBox>
Don't forget to import the correct Class. With importing the correct classpath you can include any class and try to display it, even your self-made. Just open the FXML in your SceneBuilder and use Preview to see it in action without building a custom fxml loader for it.
This should do it. Replace the "Items" with your own content. Also, take a look at the FXML reference found here for more information on using FXML.
<ChoiceBox>
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Item 1" />
<String fx:value="Item 2" />
<Separator fx:id="separator"/>
<String fx:value="Item 3" />
</FXCollections>
</items>
</ChoiceBox>

Resources