xml


Xpath mislead Expression


<?xml version="1.0" encoding="UTF-8"?>
<Matriculas>
<Matricula IdPortagem=" 1,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 19:02:24</EntryDate>
<ExitDate>2016-11-11 19:13:39</ExitDate>
<EntryPoint>Angeiras S-N</EntryPoint>
<ExitPoint>Povoa S-N</ExitPoint>
<Value>2,0</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 2,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 17:27:05</EntryDate>
<ExitDate>2016-11-11 17:27:05</ExitDate>
<EntryPoint>ER1-18</EntryPoint>
<ExitPoint>ER1-18</ExitPoint>
<Value>0,45</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 3,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 12:48:36</EntryDate>
<ExitDate>2016-11-11 12:48:36</ExitDate>
<EntryPoint>Miramar</EntryPoint>
<ExitPoint>Miramar</ExitPoint>
<Value>0,45</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 4,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-10 21:34:31</EntryDate>
<ExitDate>2016-11-10 21:34:31</ExitDate>
<EntryPoint>Povoa S-N</EntryPoint>
<ExitPoint>Povoa S-N</ExitPoint>
<Value>1,1</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
</Matriculas>
So I have this small XML here and I'm trying to get the EntryPoint of the Matricula with a Value bigger than 3.
I'm using this expression
/Matriculas//Matricula[Value>3,0]/EntryPoint
And it seems I'm doing something wrong... can anyone help me please?
I'm trying to get the EntryPoint of the Matricula with a Value bigger
than 3.
The problem here is that you are trying to compare two numbers - but XPath/XSLT expects numbers to use . dot as the decimal separator. Values using decimal comma are not considered to be numbers.
Try instead:
/Matriculas//Matricula[translate(Value, ',', '.') > 3]/EntryPoint
The above will work with XPath/XSLT 1.0. To make it future-proof, use:
/Matriculas//Matricula[number(translate(Value, ',', '.')) > 3]/EntryPoint
Of course, it would help if your input example actually contained a Matricula with a Value larger than 3.

Related Links

XSLT: Specific tag placement
Talend - getCode() error while extracting XML file
value-of select=“document($path)/ns0:element1/ns0:element2” returns NULL with SAXON-B XSLT 2.0 (saxon9)
XSD extend base with suppression of one attribute
ServiceStack Response - Change encoding?
Wrapping multiple identically named elements into a new element using XSLT
Xml schema uniqueness in entire subtree
dynamic xml nodes using xslt
xpst0003 xquery syntax error
Xsl anchor attribute
How to get start and end of a week of a specific date using xslt?
how to select elements when the root element has a lot of attributes
xsd select multiple values from enumeration or equivalent type
Issue with XSL loops and linefeeds
what is the xpath of this element
Openerp module output not generated properly

Categories

HOME
microsoftgraph
telegram
github-for-windows
redux-form
object
pascal
permissions
qpython
rtf
cumulocity
event-sourcing
alpacajs
apache2.4
simpleitk
undertow
guzzle
dataflow-diagram
php-mysqlidb
comparator
maze
custom-post-type
jackson-modules
jasmine-node
8051
soot
twiml
send
r-grid
catch-unit-test
installshield-le
openalpr
demo
glm-math
claims
wc
show-hide
httr
bluez
video-conferencing
mouseleave
monkey
sandcastle
flex-monkey
redistributable
preprocessor
lrs
mta
expectations
lean
turbo-prolog
findfirst
atan2
state-restoration
file-move
video-player
zscript
baasbox
keyup
broadband
adehabitathr
viewer
sonarqube-5.0
cocos3d
mdichild
angular-carousel
matrix-inverse
jjaql
extjs2
amslidemenu
windows-embedded-standard
http-patch
printdialog
observium
octal
mantle
idn
onmousemove
cgimage
drawtobitmap
timthumb
event-receiver
msr
cloudfiles
mtu
jqueryform
escrow
cardspace

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App