I have a query like this:
/plist/dict[1]/dict/dict/dict/key/following-sibling::dict/string[string()='Algier']
What I really want to select is the 'key' node (just before the following-sibling::dict) one.
The xml is like this :
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>en_GB</key>
<dict>
<key>Africa</key>
<dict>
<key>Algeria</key>
<dict>
<key>60390</key>
<dict>
<key>NAME</key>
<string>Algier</string>
<key>LATITUDE</key>
<string>36.7500</string>
<key>LONGITUDE</key>
<string>3.0500</string>
</dict>
<key>60391</key>
<dict>
<key>NAME</key>
<string>Some other city</string>
<key>LATITUDE</key>
<string>36.7500</string>
<key>LONGITUDE</key>
<string>3.0500</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
In other words, I want to select '60390' when the city name is 'Algier' or (60391 when city name is 'some other city').
I'm doing this in a QML XmlListModel.
Updated code
QML used:
import QtQuick 1.0
Rectangle {
id: container;
width: 360
height: 360
function onLocationModelLoaded(){
console.debug(weLocationModel.count);
}
XmlListModel{
id: weLocationModel;
source: "we_locations.plist";
query: "/*/dict/dict/dict/dict/key[following-sibling::dict[1]/key[.='NAME' and following-sibling::string[1] = 'Algier']]"
XmlRole{
name: "cityId";
query: "name()";
}
onStatusChanged: {
if (status == XmlListModel.Ready){
console.debug("Location Model Ready");
container.onLocationModelLoaded();
}
}
}
}
It seems like the nested following-sibling is not working.
for example something like:
query: "/*/dict/dict/dict/dict/key[following-sibling::dict[1]/key[.='NAME']]"
Both of these always return:
Error XPST0003 in file:///Users/Ali/qtprojects/welocationtest-build-simulator/welocationtest.app/Contents/MacOS/welocationtest, at line 2, column 97: syntax error, unexpected ], expecting )
Error XPST0003 in file:///Users/Ali/qtprojects/welocationtest-build-simulator/welocationtest.app/Contents/MacOS/welocationtest, at line 2, column 91: syntax error, unexpected ], expecting end of file
file:///Users/Ali/qtprojects/welocationtest-build-simulator/welocationtest.app/Contents/Resources/qml/welocationtest/main.qml:17:9: QML XmlRole: invalid query: "name()"
Location Model Ready
0
Could it be possible QML is not following XPath standard? THe solution works in all other path editors.
One XPath expression that selects exactly the wanted key element is this:
/*/dict/dict/dict/dict
/key
[following-sibling::dict[1]/key
[.='NAME'
and
following-sibling::string[1] = $pCity
]
]
When $pCity is set/substituted-by "Algier", this XPath expression selects:
<key>60390</key>
When $pCity is set/substituted-by "Some other city", this XPath expression selects:
<key>60391</key>
XSLT-based verification:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pCity" select="'Some other city'"/>
<xsl:template match="/">
<xsl:copy-of select=
"/*/dict/dict/dict/dict
/key
[following-sibling::dict[1]/key
[.='NAME'
and
following-sibling::string[1] = $pCity
]
]
"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied against the provided XML document:
<plist version="1.0">
<dict>
<key>en_GB</key>
<dict>
<key>Africa</key>
<dict>
<key>Algeria</key>
<dict>
<key>60390</key>
<dict>
<key>NAME</key>
<string>Algier</string>
<key>LATITUDE</key>
<string>36.7500</string>
<key>LONGITUDE</key>
<string>3.0500</string>
</dict>
<key>60391</key>
<dict>
<key>NAME</key>
<string>Some other city</string>
<key>LATITUDE</key>
<string>36.7500</string>
<key>LONGITUDE</key>
<string>3.0500</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
the wanted, correct result is produced:
<key>60391</key>
When in the above transformation we replace:
<xsl:param name="pCity" select="'Some other city'"/>
with:
<xsl:param name="pCity" select="'Algier'"/>
and apply the transformation again, then again we get the correct result:
<key>60390</key>
To get the number for a city you can use a RegEx, too (especially if QML XPath support is not good enough):
import QtQuick 1.0
Rectangle {
id: container
width: 360
height: 360
Component.onCompleted: {
loadWeLocationsFile();
}
property string weLocationsXML
signal weLocationsLoaded()
function loadWeLocationsFile() {
// load file
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.DONE) {
// get file content
weLocationsXML = doc.responseText;
// emit signal
weLocationsLoaded();
}
}
doc.open("GET", "we_locations.plist");
doc.send();
}
function getIDByName(name) {
// escape special characters for regex (maybe there is a better way to do this)
var safeName = name.replace(/[-.,?+*#^$()[\]{}\\|]/g, "\\$&");
// create regex
var regex = new RegExp("<key>(.*?)</key>\\s*<dict>\\s*<key>NAME</key>\\s*<string>" + safeName + "</string>", "m");
// execute regex
var match = regex.exec(weLocationsXML);
if (match != null && match.length > 1) {
return match[1]; // name found, group 1 contains id
} else {
return null; // no such name in XML
}
}
// Test it ...
onWeLocationsLoaded: {
console.log("Number for 'Algier':", getIDByName("Algier"));
console.log("Number for 'NotInXML':", getIDByName("NotInXML"));
console.log("Number for 'Some other city':", getIDByName("Some other city"));
}
}
Output:
Number for 'Algier': 60390
Number for 'NotInXML': null
Number for 'Some other city': 60391
If you need the number in a QML model you can create a ListModel and add the number to it.
Related
I'm facing a weird problem (IMHO) which, in short, is:
a node list passed as a parameter to a template can't be sorted.
Here's an example.
The input file is:
<root>
<a>BBB</a>
<a>AAA</a>
</root>
And the transformation is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<Root>
<xsl:call-template name="processThis">
<xsl:with-param name="nodeList" select="/*/a"/>
</xsl:call-template>
</Root>
</xsl:template>
<xsl:template name="processThis">
<xsl:param name="nodeList" />
<xsl:for-each select="$nodeList">
<xsl:sort /><!-- ***** This causes the problem -->
<xsl:variable name="thisVal" select="." />
<result value="{$thisVal}" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The expected output is:
<Root>
<result value="AAA" />
<result value="BBB" />
</Root>
But if I run the transformation, just an empty 'Root' element is generated, without child nodes.
If I comment out the line marked with '*****', the generated Root element does contain child elements, but unsorted (as one would expect in this case).
If I process the elements directly (and not in a template passing the list to process as a parameter), then I can use 'sort', and everything works as expected. Here is the 'direct' transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<Root>
<xsl:for-each select="/*/a">
<xsl:sort />
<xsl:variable name="thisVal" select="." />
<result value="{$thisVal}" />
</xsl:for-each>
</Root>
</xsl:template>
</xsl:stylesheet>
So my question is: why isn't a list passed as a parameter to a template processed with a 'sort' option?
Update from Mar 07 2016:
XmlSpy and some online XSL processors deliver the expected (sorted) output.
I've tried it with a standalone Java program, and it gives me the wrong result. Here's the program:
package my.test;
import java.io.File;
import java.io.StringWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class Transform {
public static void main(String[] args) throws Exception {
String inputFileName = "Q:\\MiscThings\\t\\a.xml";
String xslFileName = "Q:\\MiscThings\\t\\trans.xsl";
Source xmlSource = new StreamSource(new File(inputFileName));
Source xslSource = new StreamSource(new File(xslFileName));
StringWriter stringWriter = new StringWriter();
Result transformationResult = new StreamResult(stringWriter);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(xslSource);
transformer.transform(xmlSource, transformationResult);
stringWriter.flush();
String xmlResult = stringWriter.toString();
System.out.println(xmlResult);
}
}
I resolved the issue by explicitly specifying the XSL processor to be used. It seems to me that the JDK I use (I tried JRE7 and JRE8) includes an older version of XSL processor which does not process files correctly.
I downloaded Xalan 2.7.2 and specified its JAR in the 'xslt' ant task -- and immediately got the correct result.
I also tried saxon 9, and also got the correct result.
I'm surprised by the fact that a modern JRE is packaged with a flawed XSL processor. The transformation I perform is not a complicated one in my view.
I am using wso2esb-4.8.1,
I wish to change my request and response before sending to endpoint and client
so my request is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<ss:security xmlns:ss="http://eai.admc.kyt/security">
<ss:Request>
<ss:Operation_Name>securityrem</ss:Operation_Name>
<ss:customerID>
<ss:no>9875452</ss:no>
<ss:Service_Type>gsm</ss:Service_Type>
</ss:customerID>
<ss:customer>
<ss:isCredit>false</ss:isCredit>
<ss:Amount>100000</ss:Amount>
<ss:transaction_Id>4301298</ss:transaction_Id>
<ss:TransactionTypeID>228</ss:TransactionTypeID>
<!--<ss:DeductionPriorityCode>2</ss:DeductionPriorityCode>-->
</ss:customer>
</ss:Request>
</ss:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
I wish to change the ss:security element namespace with xmlns:emp="http://uri.open.gen/com" so my request should be change as per new Namespace its lke this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:paempword>emp</pr:paempword>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<emp:safety xmlns:emp="http://uri.open.gen/com">
<emp:Request>
<emp:Operation_Name>securityrem</emp:Operation_Name>
<emp:customerID>
<emp:no>9875452</emp:no>
<emp:Service_Type>gsm</emp:Service_Type>
</emp:customerID>
<emp:customer>
<emp:isCredit>false</emp:isCredit>
<emp:Amount>100000</emp:Amount>
<emp:transaction_Id>4301298</emp:transaction_Id>
<emp:TransactionTypeID>228</emp:TransactionTypeID>
<!--<emp:DeductionPriorityCode>2</emp:DeductionPriorityCode>-->
</emp:customer>
</emp:Request>
</emp:safety>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
So i have tried with xquery but its unable to do someone please responed for this
i have tried with this xquery
<x xmlns="http://ws.apache.org/ns/synapse">
declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";
declare namespace soap="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace open="http://www.ffff.org/";
declare variable $emp as xs:string+:="http://uri.open.gen/com";
declare namespace env="http://eai.jj.mmm/Envelope";
declare variable $Request xs:string+ external;
declare variable $EaiEnvelope as document-node() external;
element{'open:clientRequest'}{
element{'*:EaiEnvelope'}{$EaiEnvelope//*:EaiEnvelope/*[not(local-name()='Payload')],
element{'*:Payload'}{
element{QName($emp,concat('emp',':','safety'))}
$Request//env:Payload/*[1]/*
}}
}
</x>
but its giving exception token is not specified
Thanks in advance
If XSLT 2.0 is an option for you (for example using saxon XSLT processor). You can apply this stylesheet to youe input:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ss="http://eai.admc.kyt/security"
xmlns:emp="http://uri.open.gen/com"
version="2.0">
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ss:*">
<xsl:element name="emp:{local-name()}">
<xsl:apply-templates select="node()|#*"/>
</xsl:element>
</xsl:template>
<xsl:template match="#ss:*">
<xsl:attribute name="emp:{local-name()}">
<xsl:apply-templates select="node()|#*"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Every attribute and element in http://eai.admc.kyt/security namespace in input will be in the other namespace in the output.
One note: it won't change in the comments
Here's an XQuery option...
XML Input
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<ss:security xmlns:ss="http://eai.admc.kyt/security">
<ss:Request>
<ss:Operation_Name>securityrem</ss:Operation_Name>
<ss:customerID>
<ss:no>9875452</ss:no>
<ss:Service_Type>gsm</ss:Service_Type>
</ss:customerID>
<ss:customer>
<ss:isCredit>false</ss:isCredit>
<ss:Amount>100000</ss:Amount>
<ss:transaction_Id>4301298</ss:transaction_Id>
<ss:TransactionTypeID>228</ss:TransactionTypeID>
<!--<ss:DeductionPriorityCode>2</ss:DeductionPriorityCode>-->
</ss:customer>
</ss:Request>
</ss:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
XQuery
declare namespace emp="http://uri.open.gen/com";
declare namespace pr="http://webservices.temp.com/ProxyService";
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace open="http://www.oly.org/";
declare namespace env="http://eai.ttt.pp.hh";
declare function local:ident($node as node()) {
if ($node instance of element()) then
if (namespace-uri($node) = 'http://eai.admc.kyt/security') then
local:change-ss($node)
else
element {$node/name()} {$node/#*,
for $child in $node/node() return local:ident($child)}
else if ($node instance of attribute()) then
if (namespace-uri($node) = 'http://eai.admc.kyt/security') then
local:change-ss($node)
else
$node
else if ($node instance of comment()) then
local:change-ss($node)
else
$node
};
declare function local:change-ss($node as node()) {
if ($node instance of element()) then
element {xs:QName(concat('emp:',$node/local-name()))} {
for $node in $node/(#*|node())
return
local:ident($node)
}
else if ($node instance of attribute()) then
attribute {xs:QName(concat('emp:',$node/local-name()))} {$node}
else if ($node instance of comment()) then
comment {replace($node,'(</?)ss:','$1emp:')}
else
$node
};
local:ident(/*)
XML Output
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<pr:authentication xmlns:pr="http://webservices.temp.com/ProxyService"
soapenv:her="http://schemas.xmlsoap.org/soap/her/next"
soapenv:mustUnderstand="0">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<emp:security xmlns:emp="http://uri.open.gen/com">
<emp:Request>
<emp:Operation_Name>securityrem</emp:Operation_Name>
<emp:customerID>
<emp:no>9875452</emp:no>
<emp:Service_Type>gsm</emp:Service_Type>
</emp:customerID>
<emp:customer>
<emp:isCredit>false</emp:isCredit>
<emp:Amount>100000</emp:Amount>
<emp:transaction_Id>4301298</emp:transaction_Id>
<emp:TransactionTypeID>228</emp:TransactionTypeID>
<!--<emp:DeductionPriorityCode>2</emp:DeductionPriorityCode>-->
</emp:customer>
</emp:Request>
</emp:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
The 2 XQuery functions can be combined to make it smaller, but I thought it was a little more readable.
I want to see if a theme element exists with specified name in the following xml file.
input.xml
<data>
<artifacts>
<document id="efqw4eads">
<name>composite</name>
</document>
<theme id="1">
<name>Terrace</name>
</theme>
<theme id="2">
<name>Garage</name>
</theme>
<theme id="3">
<name>Reception</name>
</theme>
<theme id="4">
<name>Grade II</name>
</theme>
</artifacts>
</data>
I have the following code. return true statement of the method is never executed. answer always contains a null value.
public boolean themeExists(String name, Data data){
String expression = "artifacts/theme[name='"+name+"']/name/text()";
String answer = jaxbContext.getValueByXPath(data, expression, null, String.class);
if(answer == null || answer.equals("")){
return false;
}
return true;
}
This use case isn't currently supported by EclipseLink JAXB (MOXy). I have opened the following enhancement you can use to track our progress:
http://bugs.eclipse.org/413823
There is no <artifacts/> element you're look for in the first axis step. Your XPath expression should be something like
String expression = "data/theme[name='"+name+"']/name/text()";
Actually, i have a c++ code which decode a xml from a xml file with TinyXML library.
std::string = "xmlFile.xml";
TiXmlDocument doc(xml_name);
bool loadOkay = doc.LoadFile();
if (loadOkay){...}
Where xmlFile.xml
<?xml version="1.0">
<body>
....
</body>
Now I need to decode the same xml, but now I have the xml contents atfunction input.
I have thought it would be something like:
std::string contents = "<?xml version="1.0"> <body> ... </body>";
TiXmlDocument doc(contents);
bool loadOkay = doc.LoadFile();
if (loadOkay){...}
But obviously, this not work so.
How can I solve this?
Try the TiXmlDocument::Parse() method instead of the LoadFile() method. Also take a look at this question.
Can TinyXml load Xml from string instead of file?
I just upgraded Xcode to version 4.5, but I now get this error when trying to run it on my iPhone:
target specifies product type 'com.apple.product-type.application', but there's no such product type for the 'iphoneos' platform
It works fine on the simulator and it used to work in version 4.4.
edit: It can also be that the project expects you to have http://www.iosopendev.com/ installed.
My error was "target specifies product type 'com.apple.product-type.library.dynamic', but there's no such product type for the 'iphoneos' platform"
Inside of the appropriate directory, per TwiterZX's's comment, run the following commands:
sudo plutil -convert json iPhoneOSProductTypes.xcspec
sudo plutil -convert json iPhoneOSPackageTypes.xcspec
Editing these files can be made a lot easier if you use a json pretty service on your file's contents first.
After the first [ inside of iPhoneOSProductTypes.xcspec, paste:
{ "Type": "ProductType",
"Identifier": "com.apple.product-type.library.dynamic",
"Class": "PBXDynamicLibraryProductType",
"Name": "Dynamic Library",
"Description": "Dynamic library",
"IconNamePrefix": "TargetPlugin",
"DefaultTargetName": "Dynamic Library",
"DefaultBuildProperties": {
"FULL_PRODUCT_NAME": "$(EXECUTABLE_NAME)",
"MACH_O_TYPE": "mh_dylib",
"REZ_EXECUTABLE": "YES",
"EXECUTABLE_SUFFIX": ".$(EXECUTABLE_EXTENSION)",
"EXECUTABLE_EXTENSION": "dylib",
"PUBLIC_HEADERS_FOLDER_PATH": "/usr/local/include",
"PRIVATE_HEADERS_FOLDER_PATH": "/usr/local/include",
"INSTALL_PATH": "/usr/local/lib",
"DYLIB_INSTALL_NAME_BASE": "$(INSTALL_PATH)",
"LD_DYLIB_INSTALL_NAME": "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)",
"DYLIB_COMPATIBILITY_VERSION": "1",
"DYLIB_CURRENT_VERSION": "1",
"FRAMEWORK_FLAG_PREFIX": "-framework",
"LIBRARY_FLAG_PREFIX": "-l",
"LIBRARY_FLAG_NOSPACE": "YES",
"STRIP_STYLE": "debugging",
"GCC_INLINES_ARE_PRIVATE_EXTERN": "YES",
"CODE_SIGNING_ALLOWED": "YES"
},
"PackageTypes": [
"com.apple.package-type.mach-o-dylib"
]
},
After the first [ inside of iPhoneOSPackageTypes.xcspec, paste:
{ "Type": "PackageType",
"Identifier": "com.apple.package-type.mach-o-dylib",
"Name": "Mach-O Dynamic Library",
"Description": "Mach-O dynamic library",
"DefaultBuildSettings": {
"EXECUTABLE_PREFIX": "",
"EXECUTABLE_SUFFIX": "",
"EXECUTABLE_NAME": "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)",
"EXECUTABLE_PATH": "$(EXECUTABLE_NAME)"
},
"ProductReference": {
"FileType": "compiled.mach-o.dylib",
"Name": "$(EXECUTABLE_NAME)",
"IsLaunchable": "NO"
}
},
Now you need to convert those files back to binary:
sudo plutil -convert binary1 iPhoneOSProductTypes.xcspec
sudo plutil -convert binary1 iPhoneOSPackageTypes.xcspec
That should do it!
You probably lost The application part from your XCode Specifications
Exit XCode and Go to (for Xcode from MacAppStore):
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/
Backup these two files before editing: iPhoneOSPackageTypes.xcspec iPhoneOSProductTypes.xcspec
Overwrite this content to iPhoneOSPackageTypes.xcspec
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>DefaultBuildSettings</key>
<dict>
<key>CONTENTS_FOLDER_PATH</key>
<string>$(WRAPPER_NAME)</string>
<key>DOCUMENTATION_FOLDER_PATH</key>
<string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/Documentation</string>
<key>EXECUTABLES_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/Executables</string>
<key>EXECUTABLE_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>EXECUTABLE_NAME</key>
<string>$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)</string>
<key>EXECUTABLE_PATH</key>
<string>$(EXECUTABLE_FOLDER_PATH)/$(EXECUTABLE_NAME)</string>
<key>EXECUTABLE_PREFIX</key>
<string></string>
<key>EXECUTABLE_SUFFIX</key>
<string></string>
<key>FRAMEWORKS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/Frameworks</string>
<key>INFOPLIST_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/Info.plist</string>
<key>INFOSTRINGS_PATH</key>
<string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/InfoPlist.strings</string>
<key>JAVA_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Java</string>
<key>LOCALIZED_RESOURCES_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj</string>
<key>PBDEVELOPMENTPLIST_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/pbdevelopment.plist</string>
<key>PKGINFO_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/PkgInfo</string>
<key>PLUGINS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/PlugIns</string>
<key>PRIVATE_HEADERS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/PrivateHeaders</string>
<key>PUBLIC_HEADERS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/Headers</string>
<key>SCRIPTS_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Scripts</string>
<key>SHALLOW_BUNDLE</key>
<string>YES</string>
<key>SHARED_FRAMEWORKS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/SharedFrameworks</string>
<key>SHARED_SUPPORT_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/SharedSupport</string>
<key>UNLOCALIZED_RESOURCES_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>VERSIONPLIST_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)/version.plist</string>
<key>WRAPPER_NAME</key>
<string>$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)</string>
<key>WRAPPER_PREFIX</key>
<string></string>
<key>WRAPPER_SUFFIX</key>
<string>.bundle</string>
</dict>
<key>Description</key>
<string>Wrapper</string>
<key>Identifier</key>
<string>com.apple.package-type.wrapper</string>
<key>Name</key>
<string>Wrapper</string>
<key>ProductReference</key>
<dict>
<key>FileType</key>
<string>wrapper.cfbundle</string>
<key>IsLaunchable</key>
<string>NO</string>
<key>Name</key>
<string>$(WRAPPER_NAME)</string>
</dict>
<key>Type</key>
<string>PackageType</string>
</dict>
<dict>
<key>BasedOn</key>
<string>com.apple.package-type.wrapper</string>
<key>DefaultBuildSettings</key>
<dict>
<key>GENERATE_PKGINFO_FILE</key>
<string>YES</string>
</dict>
<key>Description</key>
<string>Application Wrapper</string>
<key>Identifier</key>
<string>com.apple.package-type.wrapper.application</string>
<key>Name</key>
<string>Application Wrapper</string>
<key>ProductReference</key>
<dict>
<key>FileType</key>
<string>wrapper.application</string>
<key>IsLaunchable</key>
<string>YES</string>
<key>Name</key>
<string>$(WRAPPER_NAME)</string>
</dict>
<key>Type</key>
<string>PackageType</string>
</dict>
<dict>
<key>BasedOn</key>
<string>com.apple.package-type.wrapper</string>
<key>DefaultBuildSettings</key>
<dict>
<key>CONTENTS_FOLDER_PATH</key>
<string>$(WRAPPER_NAME)/Contents</string>
<key>DOCUMENTATION_FOLDER_PATH</key>
<string>$(LOCALIZED_RESOURCES_FOLDER_PATH)</string>
<key>EXECUTABLES_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>EXECUTABLE_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>FRAMEWORKS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>INFOPLIST_PATH</key>
<string>$(WRAPPER_NAME)/ContentInfo.plist</string>
<key>INFOSTRINGS_PATH</key>
<string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/ContentInfo.strings</string>
<key>JAVA_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)</string>
<key>LOCALIZED_RESOURCES_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj</string>
<key>PLUGINS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>PRIVATE_HEADERS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>PUBLIC_HEADERS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>SCRIPTS_FOLDER_PATH</key>
<string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)</string>
<key>SHARED_FRAMEWORKS_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>SHARED_SUPPORT_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>UNLOCALIZED_RESOURCES_FOLDER_PATH</key>
<string>$(CONTENTS_FOLDER_PATH)</string>
<key>WRAPPER_SUFFIX</key>
<string></string>
</dict>
<key>Description</key>
<string>In-App Purchase Content</string>
<key>Identifier</key>
<string>com.apple.package-type.in-app-purchase-content</string>
<key>Name</key>
<string>In-App Purchase Content</string>
<key>ProductReference</key>
<dict>
<key>FileType</key>
<string>folder</string>
<key>IsLaunchable</key>
<string>NO</string>
<key>Name</key>
<string>$(WRAPPER_NAME)</string>
</dict>
<key>Type</key>
<string>PackageType</string>
</dict>
<dict>
<key>DefaultBuildSettings</key>
<dict>
<key>EXECUTABLE_NAME</key>
<string>$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)</string>
<key>EXECUTABLE_PATH</key>
<string>$(EXECUTABLE_NAME)</string>
<key>EXECUTABLE_PREFIX</key>
<string>lib</string>
<key>EXECUTABLE_SUFFIX</key>
<string>.a</string>
</dict>
<key>Description</key>
<string>Mach-O static library</string>
<key>Identifier</key>
<string>com.apple.package-type.static-library</string>
<key>Name</key>
<string>Mach-O Static Library</string>
<key>ProductReference</key>
<dict>
<key>FileType</key>
<string>archive.ar</string>
<key>IsLaunchable</key>
<string>NO</string>
<key>Name</key>
<string>$(EXECUTABLE_NAME)</string>
</dict>
<key>Type</key>
<string>PackageType</string>
</dict>
</array>
</plist>
and this content to iPhoneOSProductTypes.xcspec
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Class</key>
<string>PBXBundleProductType</string>
<key>DefaultBuildProperties</key>
<dict>
<key>FRAMEWORK_FLAG_PREFIX</key>
<string>-framework</string>
<key>FULL_PRODUCT_NAME</key>
<string>$(WRAPPER_NAME)</string>
<key>GCC_INLINES_ARE_PRIVATE_EXTERN</key>
<string>YES</string>
<key>LIBRARY_FLAG_NOSPACE</key>
<string>YES</string>
<key>LIBRARY_FLAG_PREFIX</key>
<string>-l</string>
<key>MACH_O_TYPE</key>
<string>mh_bundle</string>
<key>STRIP_STYLE</key>
<string>non-global</string>
<key>WRAPPER_EXTENSION</key>
<string>bundle</string>
<key>WRAPPER_NAME</key>
<string>$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)</string>
<key>WRAPPER_PREFIX</key>
<string></string>
<key>WRAPPER_SUFFIX</key>
<string>.$(WRAPPER_EXTENSION)</string>
</dict>
<key>DefaultTargetName</key>
<string>Bundle</string>
<key>Description</key>
<string>Generic bundle</string>
<key>HasInfoPlist</key>
<string>YES</string>
<key>HasInfoPlistStrings</key>
<string>YES</string>
<key>IconNamePrefix</key>
<string>TargetPlugin</string>
<key>Identifier</key>
<string>com.apple.product-type.bundle</string>
<key>IsWrapper</key>
<string>YES</string>
<key>Name</key>
<string>Bundle</string>
<key>PackageTypes</key>
<array>
<string>com.apple.package-type.wrapper</string>
</array>
<key>Type</key>
<string>ProductType</string>
</dict>
<dict>
<key>BasedOn</key>
<string>com.apple.product-type.bundle</string>
<key>Class</key>
<string>PBXApplicationProductType</string>
<key>DefaultBuildProperties</key>
<dict>
<key>CODE_SIGNING_ALLOWED</key>
<string>YES</string>
<key>ENTITLEMENTS_ALLOWED</key>
<string>YES</string>
<key>GCC_INLINES_ARE_PRIVATE_EXTERN</key>
<string>YES</string>
<key>GCC_SYMBOLS_PRIVATE_EXTERN</key>
<string>YES</string>
<key>INSTALL_PATH</key>
<string>$(LOCAL_APPS_DIR)</string>
<key>MACH_O_TYPE</key>
<string>mh_execute</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>YES</string>
<key>RESOURCE_RULES_REQUIRED</key>
<string>YES</string>
<key>STRIP_STYLE</key>
<string>all</string>
<key>WRAPPER_EXTENSION</key>
<string>app</string>
<key>WRAPPER_SUFFIX</key>
<string>.$(WRAPPER_EXTENSION)</string>
</dict>
<key>DefaultTargetName</key>
<string>Application</string>
<key>Description</key>
<string>Application</string>
<key>IconNamePrefix</key>
<string>TargetApp</string>
<key>Identifier</key>
<string>com.apple.product-type.application</string>
<key>Name</key>
<string>Application</string>
<key>PackageTypes</key>
<array>
<string>com.apple.package-type.wrapper.application</string>
</array>
<key>SupportsZeroLink</key>
<string>YES</string>
<key>Type</key>
<string>ProductType</string>
<key>Validation</key>
<dict>
<key>AdditionalValidationClass</key>
<string>XCiPhoneOSPlatformPlugin</string>
<key>Checks</key>
<dict>
<key>!( $(VALIDATE_PRODUCT) == NO && $(CODE_SIGN_IDENTITY) == 'iPhone Distribution' )</key>
<string>The Validate Built Product build setting was not enabled when building for Distribution.</string>
</dict>
<key>ValidationToolSpec</key>
<string>com.apple.build-tools.platform.validate</string>
</dict>
</dict>
<dict>
<key>Class</key>
<string>PBXBundleProductType</string>
<key>DefaultBuildProperties</key>
<dict>
<key>FULL_PRODUCT_NAME</key>
<string>$(WRAPPER_NAME)</string>
</dict>
<key>Description</key>
<string>In-App Purchase Content</string>
<key>HasInfoPlist</key>
<string>YES</string>
<key>HasInfoPlistStrings</key>
<string>NO</string>
<key>Identifier</key>
<string>com.apple.product-type.in-app-purchase-content</string>
<key>IsWrapper</key>
<string>YES</string>
<key>Name</key>
<string>In-App Purchase Content</string>
<key>PackageTypes</key>
<array>
<string>com.apple.package-type.in-app-purchase-content</string>
</array>
<key>Type</key>
<string>ProductType</string>
</dict>
<dict>
<key>AlwaysPerformSeparateStrip</key>
<string>YES</string>
<key>Class</key>
<string>PBXStaticLibraryProductType</string>
<key>DefaultBuildProperties</key>
<dict>
<key>CODE_SIGNING_ALLOWED</key>
<string>NO</string>
<key>EXECUTABLE_EXTENSION</key>
<string>a</string>
<key>EXECUTABLE_PREFIX</key>
<string>lib</string>
<key>EXECUTABLE_SUFFIX</key>
<string>.$(EXECUTABLE_EXTENSION)</string>
<key>FRAMEWORK_FLAG_PREFIX</key>
<string>-framework</string>
<key>FULL_PRODUCT_NAME</key>
<string>$(EXECUTABLE_NAME)</string>
<key>GCC_ENABLE_SYMBOL_SEPARATION</key>
<string>NO</string>
<key>INSTALL_PATH</key>
<string>/usr/local/lib</string>
<key>LIBRARY_FLAG_NOSPACE</key>
<string>YES</string>
<key>LIBRARY_FLAG_PREFIX</key>
<string>-l</string>
<key>MACH_O_TYPE</key>
<string>staticlib</string>
<key>PRIVATE_HEADERS_FOLDER_PATH</key>
<string>/usr/local/include</string>
<key>PUBLIC_HEADERS_FOLDER_PATH</key>
<string>/usr/local/include</string>
<key>REZ_EXECUTABLE</key>
<string>YES</string>
<key>SEPARATE_STRIP</key>
<string>YES</string>
<key>STRIP_STYLE</key>
<string>debugging</string>
</dict>
<key>DefaultTargetName</key>
<string>Static Library</string>
<key>Description</key>
<string>Static library</string>
<key>IconNamePrefix</key>
<string>TargetLibrary</string>
<key>Identifier</key>
<string>com.apple.product-type.library.static</string>
<key>Name</key>
<string>Static Library</string>
<key>PackageTypes</key>
<array>
<string>com.apple.package-type.static-library</string>
</array>
<key>Type</key>
<string>ProductType</string>
</dict>
</array>
</plist>
Restart XCode then Clean your Project and build it again for you device.