There is an auto-generated xml file.
<?xml version="1.0" encoding="UTF-8"?>
<widget id="some ID" modes="max">
<icon src="icon.png"/>
<name>StackOverflow</name>
<feature name="some feature"/>
I would like to achieve following:
subtitute modes with "full"
subtitute name with ${name}
remove <feature>
add <content src="index.html"/> in between <icon> and <name>
Can this be done?
[adding more background]
It is an website mostly made of node.js. This shell command will be run on server-side Javascript and will be executed using child_process.exec().
Since awk is also an standard GNU tool, I think it might meet your requirement.
It's an very straightforward script you can adopt.
awk '
/modes/{gsub(/modes=".*"/,"modes=\"full\"") }
/<icon/{$0=$0"\n <content src=\"index.html\"/>"}
/<name>/{gsub(/>.*</,">$name<")}
!/feature/{print}
' Your_XML_file
Output:
<?xml version="1.0" encoding="UTF-8"?>
<widget id="some ID" modes="full">
<icon src="icon.png"/>
<content src="index.html"/>
<name>$name</name>
And here's the brief explain I would give,
find modes and in your xml file, and modify as you desire
find "< icon", and insert below it.
remove the line contain feature
Related
I am trying to find xmls which are not having valid data and not process them. For example , below is a correct xml with all the data available which needs to be processes
(Loop Xpath used to read the data from xml files- Invoicing/Invoice/Serials/SerialNumber):
<?xml version='1.0' encoding='UTF-8'?>
<Invoicing>
<Invoice>
<VendorName>Contec</VendorName>
<InvoicePeriod>May</InvoicePeriod>
<InvoiceDt>2019-05-11</InvoiceDt>
<InvoiceNo>20190511</InvoiceNo>
<Serials>
<SerialNumber>
<TestLoc>HNMA01</TestLoc>
<EISSerial>PKQPLPXJC</EISSerial>
<ComcastModel>PX022ANC</ComcastModel>
<RMANo />
<ReceiptDt>05/09/2019</ReceiptDt>
<RepairDt>05/11/2019</RepairDt>
<Parts>
<Part>
<PartType>Cosmetic</PartType>
<PartId>SERVICEBUFFING</PartId>
<PartDescr>BUFF SERVC</PartDescr>
<ActionCd>RA003</ActionCd>
<FSC>FS005</FSC>
</Part>
</Parts>
</SerialNumber>
</Serials>
</Invoice>
</Invoicing>
I also get XML which are in below format,
<?xml version="1.0" encoding="UTF-8"?>
<Invoicing>
<Invoice>
<VendorName>Contec</VendorName>
<InvoicePeriod>May</InvoicePeriod>
<InvoiceDt>2017-05-01</InvoiceDt>
<InvoiceNo>20170501</InvoiceNo>
<Serials></Serials>
</Invoice>
</Invoicing>
The above xml , even though being valid is not correct..I want to identify the xmls which are in the second format without the complete data and move them into a error folder.
Thanks,
Kavin
Solution to this question is as follows :
I was able to achieve what i wanted with the solution provided by #EdMorton.
grep -L '<SerialNumber>' *.xml
But i wanted to get this done using a xml parser.
count=$(xmllint --xpath "count(//SerialNumber)" "$xml")
When the count is zero i have implemented my logic.
Thanks for all the help.
I'm trying to implement the MediaPlugin but I am running into a problem. I have done all steps in the setup instructions and get the following error:
Error: No resource found that matches the given name (at 'resource' with value '#xml/file_paths')
As explained in the setup instructions - in my Android project, I have added a folder inside the Resources-folder, called xml - containing a file called file_paths.xml with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
</paths>
I expect this problem to be related to either the above or the AndroidManifest.xml, so I'll include my complete AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.company.Kvitt" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="Kvitt.Android">
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="com.company.Kvitt.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths"/>
</provider>
</application>
</manifest>
Any help or ideas on how to solve this error are really appreciated!
The res/xml directory should be in the same sub-folder as other Resources; drawable, layout, mipmap-XXX, etc...
Do a clean all / build all just as a double check
Double-check your xml path in the project: Resources/xml/file_paths.xml
After a build, check the build artifacts for the file in obj/Debug/android/res/xml
If the resource file is not in the build artifacts the likely cause is the build action is wrong
Check that the build action on the file is set to AndroidResource
I am building a Joomla package with a component, multiple modules and a plugin.
My question is, where should I place the install.sql and uninstall.sql files, relative to the package root? Right now they are at root/com_mypackage/administrator/sql/install.mysql.utf8.sql and they are defined in the component's manifest as:
<install><!-- Runs on install -->
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
However, this doesn't seem right to me. Should I include administrator before the path in the <file> tag?
Of course, the component itself will be packed in its own .zip, to be included in the Package's XML install file.
No there is no need to this tag in administrator tag. you missing some in manifest.xml
for fully doc try:-
http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_an_install-uninstall-update_script_file
http://docs.joomla.org/Components:xml_installfile
on my end manifest.xml (my .sql in admin/install/install.mysql.utf8):-
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="2.5" method="upgrade">
<name>Social</name>
<license>Open Source License, GPL v2 based</license>
<author>me</author>
<authorEmail>developers#me.com</authorEmail>
<authorUrl>http://www.me.com</authorUrl>
<creationDate>2012-01-01</creationDate>
<copyright>2013, me</copyright>
<version>1.1</version>
<description></description>
<!-- Installation -->
<install>
<sql>
<file driver="mysql" charset="utf8">install/install.mysql.utf8.sql</file>
</sql>
</install>
<installfile>install/install.php</installfile>
<uninstall>
<sql>
<file driver="mysql" charset="utf8">install/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<uninstallfile>install/uninstall.php</uninstallfile>
and rest of
I think the problem lies in my xml.
<?xml version="1.0" encoding="UTF-8"?>
<extension version="2.5" type="plugin" group="content">
<install>
<name>Content - eya</name>
<author>eya</author>
<creationDate>February 2013</creationDate>
<copyright>(C) 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>anigag#grzeit.com</authorEmail>
<authorUrl>www.eya.com</authorUrl>
<version>2.5.0</version>
<description>Adds eya plugin ot your site</description>
<files>
<filename plugin="eya">eya.php</filename>
</files>
</install>
<administration >
<filename>admin.php</filename>
</administration>
</extension>
This is my main php file that executes the content:eya.php.
I have got another file (admin.php) that takes 2 session variables from eya.php and put them in an iframe. There are two problems. One is that I dont know if the eya.php runs everytime before admin.php (or at least once to set the session variables). The second problem is that I dont know how to display only the admin.php and nothing else.
to build an admin interface for your plugin just add the config part to your xml
<config>
<fields name="params">
<fieldset name="basic">
<field name="testfield" type="text" default="mytest" label="field_label" description="field_description" />
</fieldset>
</fields>
</config>
but I didn't get the part of your admin.php/eya.php
I use the external resources mapping by glassfish for storing user uploaded images (sun-web.xml):
<property name="downloadroot" value="from=/downloaded dir=c:\glassfishv3\downloads"/>
I store uploaded images to this directory. The first download is ok, the image is shown at the address server:8080/downloaded/image_13.png. But when the users uploads another file and replaces the image (it is really replaced in file system) the GF doesn't show new image, but the old one. Event restart and osgi-cache/generated clean doesn't help! That's very misleading and hope anyone could help me with this issue..
Ok, the issue was in JRebel! I spent the whole day, and finally found the issue! So, if anyone meets with it, the reciept to fix is to include the gf virtual path to rebel.xml like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<application>
<classpath>
<dir name="${myproject.root}\target\classes" />
</classpath>
<web>
<link target="">
<dir name="${myproject.root}\src\main\webapp" />
</link>
<link target="">
<dir name="C:\glassfish3.1" />
</link>
</web>
</application>