collect data from child links by web harvest - webharvest

Is there any way to collect data from child link for Web Harvest?
Below is a xml segment I use:
<loop item="item" index="i">
<list><var name="products"/></list>
<body>
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression><![CDATA[
declare variable $item as node() external;
for $i in $item//div[1]/p/a[#trace='auction'][1]
let $url := data($i/#href)
How can I grab data base on this new url which now is $url?
Please help me. Thx.

You just need to create another to contain this information. I have created a sample for you to understand it with ease. Please have a look:
SCRIPT:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="MainSite">http://www.appszoom.com/android_games/arcade_and_action</var-def>
<loop item="titles" index="i">
<list>
<xpath expression="//li[#class='app captureLinkBox']/div/div/span/a">
<html-to-xml>
<http url="${MainSite}"></http>
</html-to-xml>
</xpath>
</list>
<body>
<var-def name="titleURL">
<xpath expression="data(/a/#href)">
<var name="titles"/>
</xpath>
</var-def>
<file action="append" path="D:\navin.xml">
<xquery>
<xq-param name="titles"><template>${titles}</template></xq-param>
<xq-param name="titleURLContent">
<html-to-xml>
<http url="${titleURL}"></http>
</html-to-xml>
</xq-param>
<xq-expression>
<![CDATA[
declare variable $titles as node() external;
declare variable $titleURLContent as node() external;
<game>
<title>{$titles/a/text()}</title>
<downloads>{$titleURLContent//*[#id="left-bar"]/p[2]/span/text()}</downloads>
</game>
]]>
</xq-expression>
</xquery>
</file>
</body>
</loop>
</config>
OUTPUT:
<game>
<title>Clash of Clans</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>DEER HUNTER 2014</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Subway Surfers</title>
<downloads>100,000,000 - 500,000,000</downloads>
</game>
<game>
<title>RoboCop™</title>
<downloads>5,000,000 - 10,000,000</downloads>
</game><game>
<title>DragonFlight for Kakao</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Castle Clash</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Sonic Dash</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Injustice: Gods Among Us</title>
<downloads>1,000,000 - 5,000,000</downloads>
</game>
<game>
<title>Banana Kong</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Temple Run 2</title>
<downloads>100,000,000 - 500,000,000</downloads>
</game>

You do not give full code, for me to check running, but this should get you on your way:
<config>
<loop item="item" index="i">
<list><var name="products"/></list>
<body>
<var-def name="new_url">
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression><![CDATA[
declare variable $item as node() external;
for $i in $item//div[1]/p/a[#trace='auction'][1]
let $url := data($i/#href)
return
{$url}
]]></xq-expression>
</xquery>
</var-def>
<!-- now your new url is saved in webharvest variable new_url and you are free to run a
new webharvest http request using it -->
<var-def name="new_page_content">
<http url="${new_url}"/>
</var-def>
<!-- now the content of the new page has been downloaded and saved in new variable
new_page_content and you are free to query it further should you want to -->
<var-def name="contact">
<xpath expression="//a[contains(., 'contact')]/#href">
<var name="new_page_content"/>
</xpath>
</body>
</loop>
</config>

Related

SAPUI5 PlanningCalendar - binding two entities

I have the following problem:
I'm developing an APP using the flameworks PlanningCalendar, but I have two EntitySet:
Salas(3):
CAPACIDADE: 6
ID: 3
NOME: "SALA 3"
NavReservas: {__deferred: {…}}
__metadata: {type: "room_sfsf.rooms.SalasType", uri: "https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Salas(3)"}
__proto__: Object
__proto__: Object
and:
Reservas(1):
DATA_FIM: Tue Sep 18 2018 14:00:00 GMT-0300 (Horário Padrão de Brasília) {}
DATA_INICIO: Tue Sep 18 2018 12:00:00 GMT-0300 (Horário Padrão de Brasília) {}
ID: 1
ID_SALA: 3
NOME: "caio"
USUARIO: "caio.amorim"
__metadata:
type: "room_sfsf.rooms.ReservasType"
uri: "https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Reservas(1)
"
but I can not get the two to appear on the screen, but I can not get the two to appear on the related screen, Below is the view file:
<mvc:View
controllerName="br.com.successfactors.itz.MeetingRoomSuccessfactors.controller.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns:unified="sap.ui.unified"
xmlns="sap.m">
<VBox class="sapUiSmallMargin">
<PlanningCalendar
id="PC1"
startDate="{path: '/startDate'}"
rows="{path : '/Salas', parameters:{$expand: 'NavReservas'}}"
appointmentSelect="handleAppointmentSelect"
>
<toolbarContent>
<Title text="{i18n>title}" titleStyle="H4"/>
<ToolbarSpacer/>
<Button id="addButton" icon="sap-icon://add" press="handleAppointmentCreate" tooltip="Add"/>
</toolbarContent>
<rows>
<PlanningCalendarRow
id="PCR"
title="{NOME}"
text="{i18n>QuantRoom} {CAPACIDADE}"
appointments="{path: '/Reservas', templateShareable: 'true'}"
>
<!--intervalHeaders="{path: 'Employees', templateShareable: 'true'}">-->
<appointments >
<unified:CalendarAppointment
startDate="{DATA_INICIO}"
endDate="{DATA_FIM}"
icon="{}"
title="{NOME}"
text="{USER}"
type="{}"
tentative="{}"
>
</unified:CalendarAppointment>
</appointments>
<!-- <intervalHeaders>
<unified:CalendarAppointment
startDate="{start}"
endDate="{end}"
icon="{pic}"
title="{title}"
type="{type}">
</unified:CalendarAppointment>
</intervalHeaders>-->
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</mvc:View>
below the metadata file:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
Namespace="room_sfsf.rooms">
<EntityType Name="SalasType">
<Key><PropertyRef Name="ID"/></Key><Property Name="ID" Type="Edm.Int32" Nullable="false"/><Property Name="NOME" Type="Edm.String" MaxLength="30"/><Property Name="CAPACIDADE" Type="Edm.Int32"/><NavigationProperty Name="NavReservas" Relationship="room_sfsf.rooms.Nav_ReservasType" FromRole="SalasPrincipal" ToRole="ReservasDependent"/></EntityType>
<EntityType Name="ReservasType">
<Key><PropertyRef Name="ID"/></Key><Property Name="ID" Type="Edm.Int32" Nullable="false"/><Property Name="NOME" Type="Edm.String" Nullable="false" MaxLength="30"/><Property Name="USUARIO" Type="Edm.String" MaxLength="20"/><Property Name="DATA_INICIO" Type="Edm.DateTime" Nullable="false"/><Property Name="DATA_FIM" Type="Edm.DateTime" Nullable="false"/><Property Name="ID_SALA" Type="Edm.Int32"/></EntityType>
<Association Name="Nav_ReservasType"><End Type="room_sfsf.rooms.SalasType" Role="SalasPrincipal" Multiplicity="1"/><End Type="room_sfsf.rooms.ReservasType" Role="ReservasDependent" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="SalasPrincipal"><PropertyRef Name="ID"/></Principal>
<Dependent Role="ReservasDependent"><PropertyRef Name="ID_SALA"/></Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="rooms" m:IsDefaultEntityContainer="true"><EntitySet Name="Salas" EntityType="room_sfsf.rooms.SalasType"/><EntitySet Name="Reservas" EntityType="room_sfsf.rooms.ReservasType"/>
<AssociationSet Name="Nav_Reservas" Association="room_sfsf.rooms.Nav_ReservasType"><End Role="SalasPrincipal" EntitySet="Salas"/><End Role="ReservasDependent" EntitySet="Reservas"/></AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
image with the result on screen:
enter image description here
image the EntitySet:
enter image description here
Does anyone have any idea how I can solve this problem?
thank you so much.
ADD NEW COMMENT
I changed View after comment the Jorg, but not work, below:
<mvc:View
controllerName="br.com.successfactors.itz.MeetingRoomSuccessfactors.controller.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns:unified="sap.ui.unified"
xmlns="sap.m">
<VBox class="sapUiSmallMargin">
<PlanningCalendar
id="PC1"
startDate="{path: '/startDate'}"
rows="{path : '/Salas', parameters:{$expand: 'NavReservas'}}"
appointmentSelect="handleAppointmentSelect"
>
<toolbarContent>
<Title text="{i18n>title}" titleStyle="H4"/>
<ToolbarSpacer/>
<Button id="addButton" icon="sap-icon://add" press="handleAppointmentCreate" tooltip="Add"/>
</toolbarContent>
<rows>
<PlanningCalendarRow
id="PCR"
title="{NOME}"
text="{i18n>QuantRoom} {CAPACIDADE}"
appointments="{path: 'NavReservas', templateShareable: 'true'}"
>
<!--intervalHeaders="{path: 'Employees', templateShareable: 'true'}">-->
<appointments >
<unified:CalendarAppointment
startDate="{DATA_INICIO}"
endDate="{DATA_FIM}"
icon="{}"
title="{NOME}"
text="{USER}"
type="{}"
tentative="{}"
>
</unified:CalendarAppointment>
</appointments>
<!-- <intervalHeaders>
<unified:CalendarAppointment
startDate="{start}"
endDate="{end}"
icon="{pic}"
title="{title}"
type="{type}">
</unified:CalendarAppointment>
</intervalHeaders>-->
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</mvc:View>
Detail the error:
Uncaught Error: "[object Object]" is of type object, expected
sap.ui.core.URI for property "icon" of Element
sap.ui.unified.CalendarAppointment#__appointment0-__xmlview0--PCR-__xmlview0--PC1-0-0
at f.g.validateProperty (sap-ui-core.js:423)
at f.M.validateProperty (/resources/sap/ui/core/library-preload.js?eval:181)
at f.g.setProperty (sap-ui-core.js:421)
at f.setIcon (sap-ui-core.js:509)
at f.g.updateProperty (sap-ui-core.js:464)
at constructor.v (sap-ui-core.js:462)
at constructor.a.fireEvent (sap-ui-core.js:397)
at constructor.B._fireChange (sap-ui-core.js:1463)
at constructor.O.checkUpdate (/resources/sap/ui/core/library-preload.js?eval:2480)
at constructor.O.initialize (/resources/sap/ui/core/library-preload.js?eval:2475)
Image Result:
enter image description here
the browser it work!
{"d":{"results":[{"__metadata": {"type":"room_sfsf.rooms.ReservasType","uri":"https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Reservas(1)"},"ID":1,"NOME":"caio","USUARIO":"caio.amorim","DATA_INICIO":"\/Date(1537311600000)\/","DATA_FIM":"\/Date(1537318800000)\/","ID_SALA":3}]}}
enter image description here
Thanks.

Unable to manually set the intervals for Y axis

I have a HTML5 column chart in my jasper report. I need to configure the y axis and be able to set the intervals manually
I have used,
<property name="net.sf.jasperreports.chart.range.axis.tick.count" value="false"/>
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="2"/>
It has no effect on the chart
The source code is as follows
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="customizechart" pageWidth="1000" pageHeight="1000" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="23a00417-b19d-4f98-aa59-dc6422d51386">
<property name="net.sf.jasperreports.chart.range.axis.tick.count" value="false"/>
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="2"/>
<queryString>
<![CDATA[Select * from some_table]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="AppliedQuantity" class="java.lang.Float"/>
<summary>
<band height="959" splitType="Stretch">
<componentElement>
<reportElement x="0" y="0" width="960" height="500" uuid="774dd6b9-b5b9-4d3c-b518-6f7c7ca40043"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Column">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.href">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="yAxis.title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Name">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.String">
<bucketExpression><![CDATA[$F{Name}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns"/>
<multiAxisMeasure name="Measure1" class="java.lang.Integer" calculation="Nothing">
<labelExpression><![CDATA["f"]]></labelExpression>
<valueExpression><![CDATA[$F{AppliedQuantity}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>
Any ideas on this?
net.sf.jasperreports.chart.* properties apply to the charts built into the community/open source JasperReports library (which are based on JFreeChart).
For HTML5 charts - part of JasperReports Professional - what you have to do is set the yAxis.tickInterval property in the chart:
<hc:chartProperty name="yAxis.tickInterval">
<hc:propertyExpression><![CDATA[500]]></hc:propertyExpression>
</hc:chartProperty>

How can I get repeatable field values of a Liferay Dynamic Data List via API

I try to make a service for reading from Liferay 6.2 DDL.
Here is DDL structure :
<root available-locales="en_US" default-locale="en_US">
<dynamic-element dataType="string" indexType="text" localizable="false" name="Course_ID" readOnly="false" repeatable="false" required="true" showLabel="true" type="text" width="medium">
<dynamic-element dataType="boolean" indexType="keyword" localizable="true" name="Active" readOnly="false" repeatable="true" required="false" showLabel="true" type="checkbox" width="">
<dynamic-element dataType="string" indexType="keyword" localizable="true" multiple="false" name="Language" readOnly="false" repeatable="false" required="false" showLabel="true" type="select" width="">
<dynamic-element name="option22436" type="option" value="en">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[English]]>
</entry>
</meta-data>
</dynamic-element>
<dynamic-element name="option22437" type="option" value="fr">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[French]]>
</entry>
</meta-data>
</dynamic-element>
<dynamic-element name="option22438" type="option" value="de">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Deutsch]]>
</entry>
</meta-data>
</dynamic-element>
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Language]]>
</entry>
<entry name="predefinedValue">
<![CDATA[[""]]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
<dynamic-element dataType="string" indexType="keyword" localizable="true" name="Guest_URL" readOnly="false" repeatable="false" required="false" showLabel="true" type="text" width="small">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Guest URL]]>
</entry>
<entry name="predefinedValue">
<![CDATA[]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
<dynamic-element dataType="string" indexType="keyword" localizable="true" name="Registered_URL" readOnly="false" repeatable="false" required="false" showLabel="true" type="text" width="small">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Registered URL]]>
</entry>
<entry name="predefinedValue">
<![CDATA[]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Active]]>
</entry>
<entry name="predefinedValue">
<![CDATA[true]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
<dynamic-element dataType="document-library" fieldNamespace="ddm" indexType="keyword" localizable="true" name="Documents_and_Media8331" readOnly="false" repeatable="false" required="false" showLabel="true" type="ddm-documentlibrary" width="">
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Documents and Media]]>
</entry>
<entry name="predefinedValue">
<![CDATA[]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
<meta-data locale="en_US">
<entry name="label">
<![CDATA[Course ID]]>
</entry>
<entry name="predefinedValue">
<![CDATA[]]>
</entry>
<entry name="tip">
<![CDATA[]]>
</entry>
</meta-data>
</dynamic-element>
</root>
As you can see I have a repeatable checkbox container, who have 3 more element inside
structure view
I can get and iterate records list, but no idea how can I get a list with all checkboxes and iterate for their elements inside
DynamicQuery getRecordsetIdQuery = DDLRecordSetLocalServiceUtil.dynamicQuery()
.setProjection(ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("recordSetId")))
.add(RestrictionsFactoryUtil.ilike("name", courseSetName));
DynamicQuery getDdlRecordListQuery = DDLRecordLocalServiceUtil.dynamicQuery()
.add(PropertyFactoryUtil.forName("recordSetId").in(getRecordsetIdQuery));
JSONArray courseList = JSONFactoryUtil.createJSONArray();
List ddlRecordList = DDLRecordLocalServiceUtil.dynamicQuery(getDdlRecordListQuery);
if (ddlRecordList != null && ddlRecordList.size() > 0) {
int ddlRecordListSize = ddlRecordList.size();
for (int i = 0; i < ddlRecordListSize; i++) {
DDLRecord ddlRec = (DDLRecord) ddlRecordList.get(i);
Field active = ddlRec.getField("Active");
...
Do you can help me with some ideas please ?
I have three fields. solution for how to get repeated Field in portlet.
1.LanguageName (Parent and Repeated Field)
2. DocumentLinkLabel (Repeated Field)
3. DocumentLink (Child Field)
for (JournalArticle journalArticle : journalArticleList) {
Document docxml;
try {
docxml = SAXReaderUtil.read(journalArticle.getContent());
Node root = docxml.getRootElement();
List<Node> languageList = root.selectNodes("/root/dynamic-
element[#name='LanguageName']");
for (int i = 0; i < languageList.size(); i++)
{
Node languageNode = languageList.get(i);
String languageName =languageNode.selectNodes("/root/dynamic-
element[#name='LanguageName']/dynamic-content[#language-
id='en_US']").get(i).getText();
System.out.println("language Name : "+ languageName);
List<Node> documentLinkLabelList =languageNode.selectNodes("dynamic-element[#name='DocumentLinkLabel']/dynamic-element[#name='DocumentLink']");
for (int j = 0; j < documentLinkLabelList.size(); j++) {
Node languageNode1 = documentLinkLabelList.get(j);
String documentLinkName =languageNode.selectNodes("dynamic-
element[#name='DocumentLinkLabel']/dynamic-content[#language-id='en_US']").get(j).getText();
System.out.println(" document Link Lable Name : "+ documentLinkName);
String linkNameList=languageNode1.selectNodes("//dynamic-
element[#name='LanguageName']["+(i+1)+"]/dynamic-
element[#name='DocumentLinkLabel']/dynamic-element[#name='DocumentLink']/dynamic-content[#language-id='en_US']").get(j).getText();
System.out.println(" linkNameList : "+ linkNameList);
}
}
} catch (DocumentException e) {
e.printStackTrace();
}
}
You can't explicitly access DDList content in code. You have to get the xml of the record from the database and use SAXParserUtil and XPath expressions to read the values.

Why destructor of an extended binding is not called when extending binding is removed?

Creating a XulRunner application for Windows I found that if binding B extends binding A. And B is being removed, then only destructor of B is called, not followed by a call of A's destructor.
Is there something wrong with my code, or this is a XulRunner bug (I haven't find matching bug in bugzilla)?
Here is an example that I tested on XulRunner 23 and 35:
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<!--<binding-a id="A" style="-moz-binding: url('binding.xml#binding-a')"/>-->
<binding-b id="B" style="-moz-binding: url('binding.xml#binding-b')"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
binding.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("A.destructor");
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("B.destructor");
]]></destructor>
</implementation>
</binding>
</bindings>
here is the solution for your problem:
bindings.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
<method name="destruct">
<body><![CDATA[
window.print("A.destructor");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="destruct">
<body><![CDATA[
this.__proto__.__proto__.destruct.call(this);
window.print("B.destructor");
]]></body>
</method>
</implementation>
</binding>
</bindings>
bindings.css:
#namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
binding-a { -moz-binding: url("bindings.xml#binding-a"); }
binding-b { -moz-binding: url("bindings.xml#binding-b"); }
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="bindings.css" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<binding-a id="A"/>
<binding-b id="B"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
I know that it is a hack in fact but it works.

Infinite Loop when parse XML File to Flat Flie. Bug SpringBatch or Not

I tried to parse an xml file to flatefile. All worked fine except at the end. In debug Mode the cause of the infinite loop is due to the method moveCursorToNextFragment( reader) in org.springframework.batch.item.xml.StaxEventItemRe ader.class.
More precisily in this part of method
while (reader.peek() != null && !reader.peek().isStartElement()) {
reader.nextEvent();
}
it seems that these conditions are not sufficient to recognize the end of the document.
I replace this part of code by this code to be sure the end of the document test
while (reader.peek() != null && !reader.peek().isStartElement() && !reader.peek().isEndDocument()) {
reader.nextEvent();
}
if (reader.peek() == null || reader.peek().isEndDocument()) {
return false;
}
below my context file and the link for an INSEE xmlfile : http://lei-france.insee.fr/Telechargement.do
I always taked the full file.
Here is my context file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource"/>
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"
p:jobRepository-ref="jobRepository"
p:taskExecutor-ref="taskExecutor" />
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
p:dataSource-ref="dataSource"
p:transactionManager-ref="transactionManager" />
<bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
<!-- DATASOURCE -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:#gulli:1521:OPE" />
<property name="username" value="xxxxxx" />
<property name="password" value="xxx" />
</bean>
<!-- ITEM READER -->
<bean id="itemReader" scope="step" class="org.springframework.batch.item.xml.StaxEventItemReader"
p:resource="insee/lei.xml"
p:fragmentRootElementName="LEIRecord"
p:unmarshaller-ref="inseeMarshaller" />
<bean id="inseeMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"
p:autodetectAnnotations="true" p:encoding="UTF-8">
<property name="aliases">
<props>
<prop key="LEIDirectory">fr.cdn.dtc.etudes.emir.insee.LEIDirectory</prop>
<prop key="LEIRecord">fr.cdn.dtc.etudes.emir.insee.LEIRecord</prop>
<prop key="LegalEntity">fr.cdn.dtc.etudes.emir.insee.LegalEntity</prop>
<prop key="OtherIdentifiers">fr.cdn.dtc.etudes.emir.insee.OtherIdentifiers</prop>
<prop key="OtherNames">fr.cdn.dtc.etudes.emir.insee.OtherNames</prop>
<prop key="RelatedLEI">fr.cdn.dtc.etudes.emir.insee.RelatedLEI</prop>
<prop key="Event">fr.cdn.dtc.etudes.emir.insee.Event</prop>
<prop key="OtherAddresses">fr.cdn.dtc.etudes.emir.insee.OtherAddresses</prop>
</props>
</property>
</bean>
<!-- ITEM WRITER DELIMETED LENGTH-->
<bean id="itemWriterFile" class="org.springframework.batch.item.file.FlatFileItemWriter"
p:resource-ref="outputDelimitedResource"
p:lineAggregator-ref="lineAggregator"
p:shouldDeleteIfExists="true"
/>
<bean id="outputDelimitedResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="target/outputs/inseeOutput.txt" />
</bean>
<bean id="lineAggregator" class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"
p:delimiter=";"
p:fieldExtractor-ref="fieldExtractor" />
<bean id="fieldExtractor" class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"
p:names="le" />
<batch:job id="inseeJob" job-repository="jobRepository" >
<batch:step id="inseeStep">
<batch:tasklet>
<batch:chunk reader="itemReader" writer="itemWriterFile" commit-interval="10" />
<batch:transaction-attributes isolation="DEFAULT" propagation="REQUIRED" timeout="30"/>
</batch:tasklet>
</batch:step>
</batch:job>
</beans>
Best Regards
Clément

Resources