check values of 2 XPath-Expressions
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Thu Aug 09, 2018 3:29 pm
check values of 2 XPath-Expressions
Hi,
I want to test if values of nodes are the same:
Why isn't this working?
I want to test if values of nodes are the same:
Code: Select all
<xsl:if test="'//ab:person1/ab:gender' and '//ab:person2/ab:gender' '">
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: check values of 2 XPath-Expressions
Hi,
You usually need to use the "=" sign to compare two nodes or strings in XSLT. But there is not much context in what you posted to help further.
Usually when you post about an XSLT problem, posting a small sample XML and XSLT stylesheet help others understand better what you want to do.
Regards,
Radu
You usually need to use the "=" sign to compare two nodes or strings in XSLT. But there is not much context in what you posted to help further.
Usually when you post about an XSLT problem, posting a small sample XML and XSLT stylesheet help others understand better what you want to do.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 4
- Joined: Thu Aug 09, 2018 3:29 pm
Re: check values of 2 XPath-Expressions
I changed my example to following (working) problem case:
The result should be:
Using "=" didn't worked :/
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ab="http://ab.example.net/V1.0/Schema" exclude-result-prefixes="ab">
<xsl:template match="/">
<Data>
<xsl:if test="'//ab:kov-data/ab:person1/ab:gender' = '//ab:kov-data/ab:person2/ab:gender'">
:)
</xsl:if>
</Data>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<ab:kov-data xmlns:ab="http://ab.example.net/V1.0/Schema">
<ab:person1>
<ab:gender>m</ab:gender>
</ab:person1>
<ab:person2>
<ab:gender>m</ab:gender>
</ab:person2>
</ab:kov-data>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?><Data>:)</Data>
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: check values of 2 XPath-Expressions
Hi,
If you add those extra ' simple quotes around XPath expressions, they become simple strings.
So you should remove the simple quotes and obtain something like:
Regards,
Radu
If you add those extra ' simple quotes around XPath expressions, they become simple strings.
So you should remove the simple quotes and obtain something like:
Code: Select all
<xsl:if test="//ab:kov-data/ab:person1/ab:gender = //ab:kov-data/ab:person2/ab:gender">
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service