When I try to get the attribute of URL in a test XML:
<Test> <Item URL="http://127.0.0.1?a=1&b=2"/>
</Test>
After I call: attr=xmlGetProp(cur, BAD_CAST "URL");
The libxml2 give a message: Entity: line 1: parser error : EntityRef: expecting ';'
and return value of attr is "http://127.0.0.1?a=1=2"
How can I get the completion attribution of URL? Thanks
You cannot get the “correct” URL here because the XML file is not well-formed. the & should have been written as &. You have to ask the creator of the XML file to create a syntactically valid, well-formed XML file.
XML is not created by just putting strings together, they also have to be encoded properly.
Related
I have a postgres data-config file.
<dataConfig>
<dataSource driver=”org.postgresql.Driver” url=”jdbc:postgresql://127.0.0.1:5432/mydb” user=”user” password=”pw” />
...
</dataConfig>
But when I run it, it shows error
Data Config problem: Open quote is expected for attribute "driver" associated with an element type "dataSource".
What's the problem here. is driver information that I put wrong?
Your quotes are wrong.
” and " are not the same kind of quotes (see the different presentation). Only " is a valid double quote in an XML file (and in most/all programming contexts).
The examples in your config file seems to have been mangled by a blog or a text editor on the way.
I use Gatling to test against an API responding with this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<sam:HentAktiveSamtykkerMedPartrefResponse xmlns:sam="urn:gjensidige:forsikring:samtykke">
<sam:samtykke>
<sam:idNr>01018448285</sam:idNr>
<sam:partref>0005009147</sam:partref>
<sam:utfortAv></sam:utfortAv>
<sam:navn></sam:navn>
<sam:navnUtvidet></sam:navnUtvidet>
<sam:svar>J</sam:svar>
How can I script that the response must contain the element:
<sam:svar>
?
I guess something in the lines of:
.check(xpath("whathere").exists)
But what should be stated as "whathere"?
The xpath would look something like : /*/SOAP-ENV:Body/descendant::*[name()='sam:navn']/text() this should extract the value from <sam:navn></sam:navn>.
I am using pollenrich in my code to get the message from the queue:
<pollEnrich uri="activemq:queueName" timeout="5000"/>
Now, I want to read the timeout value from config file declared in etc folder.
Something like this:
<pollEnrich uri="file:inbox?fileName=data.txt" timeout="{{readTimeout}}"/>
While doing so, I am getting the following error:
org.xml.sax.SAXParseException : cvc-datatype-valid.1.2.1: '{{readTimeout}}' is not a valid value for 'integer'
This error only comes for pollenrich and nowhere else in my code. I am able to use other properties from config file in the same camel-context.
e.g.,
<from uri="timer://TestTimer?period={{timer.interval}}&delay={{startupDelay}}/>
See the documentation at: http://camel.apache.org/using-propertyplaceholder.html at the section titled Using property placeholders for any kind of attribute in the XML DSL
I am new to json-ld and rdflib usage. I have json-ld file with #context and #graph sections inside.
I want to use rdflib open to load this graph.
When I try using parse() method, with format='n3', I am getting error
BadSyntax: at line 5 of <>:
Bad syntax (expected '.' or '}' or ']' at end of statement) at ^ in:
If I give format='json-ld', it says No plugin registered for (json-ld, )
If I don't give any format parameter then it says,
SAXParseException: file:composition.json-ld:1:0: not well-formed (invalid token)
rdflib.Graph().load('composition.json-ld')
Error SAXParseException: not well-formed (invalid token)
rdflib.Graph().load('composition.json-ld', format='json-ld')
Error PluginException: No plugin registered for (json-ld, <class 'rdflib.parser.Parser'>)
f= open('filename.json-ld', 'rb')
rdflib.Graph().parse(data=f.read(), format='json-ld') ==> Error PluginException: No plugin registered for (json-ld, <class 'rdflib.parser.Parser'>)
I checked json-ld file in json-ld playground. It is correct.
Am I missing something in syntax for parsing here?
Did you install the JSON-LD plugin? If not, do a
pip install rdflib-jsonld
All,
I try to load the FreeMarker template from database in the Smooks configuration file and use the build-ins INTERPRET to parse the string as template. However, the output is exactly the template I stored in the database.
The following is part of the Smooks configuration file:
....
<resource-config selector="hs:TravelerProfile">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
<db:executor executeOnElement="hs:TravelerProfile" datasource="StagingDS">
<db:statement>select freeMarker_template from template_lookup where agencyid='111';
</db:statement>
<db:resultSet name="mytemplate" />
</db:executor>
<ftl:freemarker applyOnElementNS="www.travel.com" applyOnElement="TravelerProfile">
<ftl:template>
< !--
<#assign templateSource = r"${mytemplate[0].freeMarker_template}">
<#assign inlineTemplate = [templateSource, "myInlineTemplate"]?interpret>
<#inlineTemplate/>
-- >
</ftl:template>
</ftl:freemarker>
.....
The template I stored in the database is like following:
<#ftl ns_prefixes={"D":"www.hhs.gov/travel"}>
<?xml version="1.0" encoding="UTF-8"?>
<po:PoHeadersInterfaceCollection xmlns:po="https://www.travel.com/xmlns/financial/po112007.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.travel.com/xmlns/financial/po112007.xsd">
<po:PoHeadersInterface>
<po:interfaceSourceCode>VendorName</po:interfaceSourceCode>
<po:poLinesInterfaceCollection>
<po:PoLinesInterface>
<po:PoDistributionsInterfaceCollection>
<po:PoDistributionsInterface>
<po:destinationOrganizationId>${TravelerProfile.TravelerOfficeCode}
</po:destinationOrganizationId>
</po:PoDistributionsInterface>
</po:PoDistributionsInterfaceCollection>
</po:PoLinesInterface>
</po:poLinesInterfaceCollection>
</po:PoHeadersInterface>
</po:PoHeadersInterfaceCollection>
====================================
For some reason, the output is exactly the above template itself. "${TravelerProfile.TravelerOfficeCode}" has not been evaluated! Please help!!!
Thank you!!!
Agnes
Sine mytemplate[0].freeMarker_template returns the template source code itself (or at least I assume that), and since you are using a raw string literal (r"..."), the source code of your template will be literally ${mytemplate[0].freeMarker_template}, which is then evaluated by ?interpret to the template source code. The corrected template would be:
<#assign inlineTemplate = [mytemplate[0].freeMarker_template, "myInlineTemplate"]?interpret>
<#inlineTemplate/>
which can be also written as:
<#([mytemplate[0].freeMarker_template, "myInlineTemplate"]?interpret) />
or if you don't need the "myInlineTemplate" template name:
<#mytemplate[0].freeMarker_template?interpret />