I want to do some image detection based on payload information in XSLT (with Xpath 2.0). I have found out that all images of the format I wish to detect start with the characters "jP" or "OQ" in the payload. When the element contains the substrings "JP" or "OQ" as the first characters in the element, I want to create a new element yes or something similar, based on which my information flow (Oracle SOA suite 12c) will go a certain direction. I have an example of my payload and my current XSLT underneath. My question is why my XSLT does not function yet, and if you would tackle my topic otherwise.
My payload looks something like this:
<ns3:BlablablaExample>
<ns3:Attachments>
<ns3:Images>
<ns3:Image>
<ns3:AttachmentID>11223344</ns3:AttachmentID>
<ns3:MetaData>
<ns3:OriginalTimestamp>2020-11-10T10:52:07.539Z</ns3:OriginalTimestamp>
<ns3:CreationTimestamp>2020-11-10T10:52:07.539Z</ns3:CreationTimestamp>
</ns3:MetaData>
<ns3:DataSource>jPRandOmD4t4AndSTu77/9j/4AAQSkZJRgABAQAAAQABAAD/5QAJSWRlbnRpeP/bAEMABgQFBgUEBgYFBgcHBggKEAoKCQkKFA4PDBAXFBgYFxQWFhodJR8aGyMcFhYgLCAjJicpKikZHy0wLSgwJSgpKP/bAEMBBwcHCggKEwoKEygaFhooKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCullullkokKoKokokCgoKCgoKCgoKCgoKP/AABEIAoAB4AMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h4xxF0R3alOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPEigAooooAKKKKACiiigAooooAKKKKACiiigAooo))))0000oo)oooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooo))oo)))000oooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//Z</ns3:DataSource>
</ns3:Image>
</ns3:Images>
</ns3:Attachments>
</ns3:BlablablaExample>
I imagine my XSLT will look something like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:ns3="http://www.randomnamespace.com/example/awesomestuff">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="text()"/>
<xsl:for-each select="ns3:BlablablaExample/ns3:Attachments/ns3:Images/ns3:Image">
<xsl:choose>
<xsl:when test="substring(/ns3:DataSource,1,2)" == "jP" || "OQ">
<JPEG2000>Yes</JPEG2000>
</xsl:when>
<xsl:otherwise>
<JPEG2000>No</JPEG2000>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
However, as I mentioned, the xslt doesnt work. My question is, what is wrong with the above XSLT, and how in your opinion would you perhaps tackle this problem otherwise? :)
Thank you kindly!
Jesper