Ant: Remove multiple lines if keyword match - ant

I have an XML file which contains the following:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
<feature name="Capture">
<param name="android-package" value="org.apache.cordova.mediacapture.Capture" />
</feature>
<feature name="Battery">
<param name="android-package" value="org.apache.cordova.batterystatus.BatteryListener" />
</feature>
How can I delete a full <feature> tag based on its name using Ant script?
For example: If "Battery" is found in the xml, delete the following:
<feature name="Battery">
<param name="android-package" value="org.apache.cordova.batterystatus.BatteryListener" />
</feature>

Ant can use a XSLT stylesheet to process XML files.
Example
├── build.xml
├── data.xml
├── process.xsl
└── target
└── output.xml
build.xml
<project name="demo" default="build">
<target name="init">
<mkdir dir="target"/>
</target>
<target name="build" depends="init">
<xslt style="process.xsl" in="data.xml" out="target/output.xml"/>
</target>
<target name="clean">
<delete dir="target"/>
</target>
</project>
process.xsl
Notice how an Xpath expression is used to filter out the feature tags name "Battery":
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/data">
<data>
<xsl:apply-templates select="feature[#name!='Battery']"/>
</data>
</xsl:template>
<xsl:template match="feature">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
data.xml
<data>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
<feature name="Capture">
<param name="android-package" value="org.apache.cordova.mediacapture.Capture" />
</feature>
<feature name="Battery">
<param name="android-package" value="org.apache.cordova.batterystatus.BatteryListener" />
</feature>
</data>
target/output.xml
The formatted result:
<data>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer"/>
</feature>
<feature name="Capture">
<param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
</feature>
</data>

Related

Why is my ORB SLAM 2 launch file crashing?

I am using ROS Melodic on Ubuntu 18.04. I was trying to implement orb slam 2 on a usb camera using this tutorial:https://medium.com/#mhamdaan/implementing-orb-slam-on-ubuntu-18-04-ros-melodic-606e668deffa
I followed all the steps mentioned, but when I launch the roslaunch usb_cam usb_cam-test.launch and roslaunch orb_slam2_ros orb_slam2_p.launch files together in separate terminals, the code crashes.
I get an error:
Enable localization only: false
[orb_slam2_mono-1] process has died [pid 12015, exit code -11, cmd /home/nidhi/tutorials/devel/lib/orb_slam2_ros/orb_slam2_ros_mono /camera/image_raw:=/camera/rgb/image_raw __name:=orb_slam2_mono __log:=/home/nidhi/.ros/log/3be66574-b74a-11ec-8b99-00e18cb0f65d/orb_slam2_mono-1.log].
log file: /home/nidhi/.ros/log/3be66574-b74a-11ec-8b99-00e18cb0f65d/orb_slam2_mono-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done
I am not able to understand what is going wrong through this error. Also I'll mention that the roslaunch usb_cam usb_cam-test.launch . The launch file I'm using for slam is as follows:
<launch>
<node name="orb_slam2_mono" pkg="orb_slam2_ros"
type="orb_slam2_ros_mono" output="screen">
<remap from="camera/camera_info" to="usb_cam/camera_info" />
<remap from="camera/image_raw" to="usb_cam/image_raw" />
<param name="publish_pointcloud" type="bool" value="true" />
<param name="publish_pose" type="bool" value="true" />
<param name="localize_only" type="bool" value="false" />
<param name="reset_map" type="bool" value="true" />
<!-- static parameters -->
<param name="load_map" type="bool" value="false" />
<param name="map_file" type="string" value="map.bin" />
<param name="voc_file" type="string" value="$(find orb_slam2_ros)/orb_slam2/Vocabulary/ORBvoc.txt" />
<param name="pointcloud_frame_id" type="string" value="map" />
<param name="camera_frame_id" type="string" value="camera_link" />
<param name="min_num_kf_in_map" type="int" value="5" />
<!--ORB parameters-->
<param name="/ORBextractor/nFeatures" type="int" value="2000" />
<param name="/ORBextractor/scaleFactor" type="double" value="1.2" />
<param name="/ORBextractor/nLevels" type="int" value="8" />
<param name="/ORBextractor/iniThFAST" type="int" value="20" />
<param name="/ORBextractor/minThFAST" type="int" value="7" />
<!-- Camera parameters -->
<!-- Camera frames per second -->
<param name="camera_fps" type="int" value="30" />
<!-- Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale) -->
<param name="camera_rgb_encoding" type="bool" value="true" />
<!--If the node should wait for a camera_info topic to take the camera calibration data-->
<param name="load_calibration_from_cam" type="bool" value="true" />
</node>
</launch>

Get XMPP Chat History OpenFire

I am trying to implement a chat application using XMPPFramework in iOS, using OpenFire server. My chat is working fine, I am trying to retrieve chat history from server. Ofcourse I have enabled Message Archiving on Server. This is the Request I am sending
<iq type="get">
<retrieve xmlns="urn:xmpp:archive" with="dev_user80#mydomain">
<set xmlns="http://jabber.org/protocol/rsm">
<max>100</max>
</set>
</retrieve>
</iq>
This is the response I am getting.
<iq xmlns="jabber:client" type="error" to="dev_user103#mydomain/6i0qoo9tek">
<retrieve xmlns="urn:xmpp:archive" with="dev_user80#mydomain">
<set xmlns="http://jabber.org/protocol/rsm">
<max>100</max>
</set>
</retrieve>
<error code="503" type="cancel">
<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
</service-unavailable>
</error>
</iq>
I have gone through all the solutions I could find on the internet but could not find a satisfying solution
change urn:xmpp:archive to urn:xmpp:archive:auto
I had the same issue and determined this by running a discovery request: http://xmpp.org/extensions/xep-0136.html#disco
I sent this IQ:
<iq from='user#mydomain.com'
id='disco1'
to='mydomain.com'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
My Openfire server with the Monitoring plugin enabled returned this result:
<iq xmlns="jabber:client" type="result" id="disco1" from="mydomain.com" to="user#mydomain.com/resource">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="server" name="Openfire Server" type="im" />
<identity category="pubsub" type="pep" />
<feature var="http://jabber.org/protocol/pubsub#retrieve-default" />
<feature var="http://jabber.org/protocol/pubsub#purge-nodes" />
<feature var="vcard-temp" />
<feature var="http://jabber.org/protocol/pubsub#subscribe" />
<feature var="http://jabber.org/protocol/pubsub#subscription-options" />
<feature var="http://jabber.org/protocol/pubsub#create-nodes" />
<feature var="http://jabber.org/protocol/pubsub#outcast-affiliation" />
<feature var="msgoffline" />
<feature var="http://jabber.org/protocol/pubsub#get-pending" />
<feature var="http://jabber.org/protocol/pubsub#multi-subscribe" />
<feature var="http://jabber.org/protocol/pubsub#presence-notifications" />
<feature var="urn:xmpp:ping" />
<feature var="jabber:iq:register" />
<feature var="http://jabber.org/protocol/pubsub#delete-nodes" />
<feature var="http://jabber.org/protocol/pubsub#config-node" />
<feature var="urn:xmpp:archive:manage" />
<feature var="http://jabber.org/protocol/pubsub#retrieve-items" />
<feature var="http://jabber.org/protocol/pubsub#auto-create" />
<feature var="http://jabber.org/protocol/disco#items" />
<feature var="http://jabber.org/protocol/pubsub#item-ids" />
<feature var="http://jabber.org/protocol/pubsub#meta-data" />
<feature var="urn:xmpp:mam:0" />
<feature var="jabber:iq:roster" />
<feature var="http://jabber.org/protocol/pubsub#instant-nodes" />
<feature var="http://jabber.org/protocol/pubsub#modify-affiliations" />
<feature var="http://jabber.org/protocol/pubsub#persistent-items" />
<feature var="http://jabber.org/protocol/pubsub#create-and-configure" />
<feature var="http://jabber.org/protocol/pubsub" />
<feature var="http://jabber.org/protocol/pubsub#publisher-affiliation" />
<feature var="http://jabber.org/protocol/pubsub#access-open" />
<feature var="http://jabber.org/protocol/pubsub#retrieve-affiliations" />
<feature var="jabber:iq:version" />
<feature var="http://jabber.org/protocol/pubsub#retract-items" />
<feature var="urn:xmpp:time" />
<feature var="http://jabber.org/protocol/pubsub#manage-subscriptions" />
<feature var="jabber:iq:privacy" />
<feature var="jabber:iq:last" />
<feature var="http://jabber.org/protocol/commands" />
<feature var="http://jabber.org/protocol/offline" />
<feature var="urn:xmpp:carbons:2" />
<feature var="http://jabber.org/protocol/address" />
<feature var="http://jabber.org/protocol/pubsub#publish" />
<feature var="http://jabber.org/protocol/pubsub#collections" />
<feature var="http://jabber.org/protocol/pubsub#retrieve-subscriptions" />
<feature var="urn:xmpp:archive:auto" />
<feature var="http://jabber.org/protocol/disco#info" />
<feature var="jabber:iq:private" />
<feature var="http://jabber.org/protocol/rsm" />
</query>
</iq>
You can see that Automatic Archiving (urn:xmpp:archive:auto) and Archive Management (urn:xmpp:archive:manage) are supported, but Manual Archiving (urn:xmpp:archive:manual) and Archiving Preferences (urn:xmpp:archive:pref) are not.
XEP-0313 is also supported (listed as urn:xmpp:mam:0) and can retrieve archived messages: http://xmpp.org/extensions/xep-0313.html

org.apache.cordova.facebook.Connect plugin error

I am using org.apache.cordova.facebook.Connect plug-in and I am having this error.
ERROR: Plugin 'org.apache.cordova.facebook.Connect' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"org.apache.cordova.facebook.Connect165525704",
"org.apache.cordova.facebook.Connect",
"init",
[
"app id"
]
]
my cordova version is 3.5.0.
I’ve try to add appname/plugins/plugin.xml to this.
<feature name="FacebookConnectPlugin">
<param name="ios-package" value="FacebookConnectPlugin"/>
<param name="onload" value="true" />
</feature>
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.4.0">
<param name="APP_ID" value="appid" />
<param name="APP_NAME" value="appname" />
</gap:plugin>
<plugin name="FacebookConnectPlugin" value="FacebookConnectPlugin" />
but no luck!! I’ve Change FB.login to facebookConnectPlugin.login but again no luck..
one more thing my application use contacts to send invitations, so in my ios device, settings/privacy/contacts I can see that my application, but in Facebook I can't see my application. I I’ve already gave permission like this.
<feature name="FacebookConnectPlugin">
<param name="ios-package" value="FacebookConnectPlugin" />
<param name="onload" value="true" />
</feature>
<plugin name="FacebookConnectPlugin" value="FacebookConnectPlugin" />
<access origin="https://m.facebook.com" />
<access origin="https://graph.facebook.com" />
<access origin="https://api.facebook.com" />
<access origin="https://*.fbcdn.net" />
<access origin="https://*.akamaihd.net" />
<feature name="Contacts">
<param name="ios-package" value="CDVContacts" />
</feature>
please help.!!!!

navigator is not working inphonegap

Hello guys I got an issue with navigator in my previous app it was working but now it is not working i tried in many way but couldn't figure out the issue.
phonegap -v is 3.3.0-0.19.6
cordova -v is 3.3.1-0.4.2
for installing plugins i tried below types
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.dialogs
Below is my config.xml file
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.company.multipleScreen" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Hello Cordova</name>
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<name>testing</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<feature name="Camera">
<param name="ios-package" value="CDVCamera" />
</feature>
<feature name="Media">
<param name="ios-package" value="CDVSound" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
<param name="onload" value="true" />
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture" />
</feature>
<feature name="Globalization">
<param name="ios-package" value="CDVGlobalization" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
The code i tried to implement for showing alert is
navigator.notification.alert("Unable to connect to server !");
and my other requirement is camera it is also not working
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
function onSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
In the current Cordova version 3.4.0 you have to manually install all plugins via cordova plugin add
So in your case, referring to https://github.com/apache/cordova-plugin-dialogs/blob/dev/doc/index.md, you need to do:
cordova plugin add org.apache.cordova.dialogs
I would recommend reading the documentation about plugins:
http://docs.phonegap.com/en/3.4.0/cordova_plugins_pluginapis.md.html#Plugin%20APIs
Issue is fixed by adding
cordova plugin add org.apache.cordova.device
cordova plugin add org.apache.cordova.console

Phonegap 2.9.0 error:deprecated as of Cordova version 2.6.0

When building facebook demo app. I am getting console output like this.
2013-09-23 14:02:36.548 Phonegapfbdemo[3708:c07] Multi-tasking -> Device: YES, App: YES
2013-09-23 14:02:38.532 Phonegapfbdemo[3708:c07] Resetting plugins due to page load.
2013-09-23 14:02:40.173 Phonegapfbdemo[3708:c07] DEPRECATION NOTICE: The Connection ReachableViaWWAN return value of '2g' is deprecated as of Cordova version 2.6.0 and will be changed to 'cellular' in a future release.
2013-09-23 14:02:40.813 Phonegapfbdemo[3708:c07] Finished load of: file:///Users/chintanshah/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/60F4DA36-DB97-49D0-81B4-719335C74203/Phonegapfbdemo.app/www/index.html
if any body has solved this issue. plz help me
here is my code:
config.xml
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation"/>
</feature>`enter code here`
<feature name="Device">
<param name="ios-package" value="CDVDevice"/>
</feature>
<feature name="Accelerometer">
<param name="ios-package" value="CDVAccelerometer"/>
</feature>
<feature name="Compass">
<param name="ios-package" value="CDVLocation"/>
</feature>
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
<feature name="Camera">
<param name="ios-package" value="CDVCamera"/>
</feature>
<feature name="Contacts">
<param name="ios-package" value="CDVContacts"/>
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile"/>
</feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection"/>
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification"/>
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer"/>
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture"/>
</feature>
<feature name="Battery">
<param name="ios-package" value="CDVBattery"/>
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
</feature>
<feature name="Echo">
<param name="ios-package" value="CDVEcho"/>
</feature>
<feature name="Globalization">
<param name="ios-package" value="CDVGlobalization"/>
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser"/>
</feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage"/>
</feature>
<feature name="org.apache.cordova.facebook.Connect">
<param name="ios-package" value="FacebookConnectPlugin" />
</feature>
and my index.html looks like
<div id="deviceready"></div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<!-- cordova facebook plugin -->
<script src="js/cdv-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="js/facebook_js_sdk.js"></script>
<script src="js/_config.js"></script>
<script src="js/ui.js"></script>
<script src="js/auth.js"></script>
<script src="js/feed.js"></script>
<script src="js/graph_api.js"></script>
<script src="js/requests.js"></script>
<!--<script src="js/credits.js"></script>-->
<script>
// Initialize the Facebook SDK
document.addEventListener('deviceready', function() {
FB.init({
appId: '177390275777596',
nativeInterface: CDV.FB,
useCachedDialogs: false
});
FB.getLoginStatus(handleStatusChange);
authUser();
updateAuthElements();
});

Resources