Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

[XSLT, XPath] XPath functions min and max behaving inconsistently

DominionSpyMar 28 2007 — edited Mar 28 2007
Products: JDeveloper 10.1.3.0.4

I'm using the Oracle XML Parser v2 in JDeveloper to do some XSLT work. At one point in the file, I need to get the minimum value from a set of string nodes.

Example source XML:
<?xml version="1.0" encoding="UTF-8"?>
<employees>
  <employee>
    <name>Greg</name>
    <age>32</age>
  </employee>
  <employee>
    <name>Helen</name>
    <age>45</age>
  </employee>
  <employee>
    <name>Frank</name>
    <age>41</age>
  </employee>
</employees>
Example XSLT:
<?xml version="1.0" encoding="windows-1252"?>
<xsl:transform version="2.0"
  xmlns="people"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <xsl:template match="employees">
    <people>
      <first-name><xsl:value-of select="min(//name)"/></first-name>
    </people>
  </xsl:template>
</xsl:transform>
In this example, I'm using the min function to get the lowest value of all name nodes in the source XML. However, this doesn't work - I get a runtime error:
XML-23029: (Error) FORG0001: invalid value for cast/constructor
So I did some testing and found that I got some strange results from min and max.

max((4,2,6,3,1,7)) gives 7 - Correct
max(('f','h','a','r','z')) gives z - Correct

min((4,2,6,3,1,7))
min(('f','h','a','r','z'))
both throw this error:
XML-22900: (Fatal Error) An internal error condition occurred.
javax.xml.transform.TransformerException: XML-22900: (Fatal Error) An internal error condition occurred.
	at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:840)
	at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:436)
	...
Caused by: java.lang.NullPointerException
	at oracle.xml.xslt.XSLTContext.reset(XSLTContext.java:541)
	at oracle.xml.xslt.XSLProcessor.processXSL(XSLProcessor.java:372)
	at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:420)
	... 2 more
---------
java.lang.NullPointerException
	at oracle.xml.xslt.XSLTContext.reset(XSLTContext.java:541)
	at oracle.xml.xslt.XSLProcessor.processXSL(XSLProcessor.java:372)
	at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:420)
	...
Where age is defined as an xs:integer
max(//age) gives 45 - Correct
min(//age) gives 32 - Correct

Where name is defined as an xs:string
max(//name)
min(//name)
both throw this error:
XML-23029: (Error) FORG0001: invalid value for cast/constructor
In the documentation for the XPath min and max functions it specifies that values of xs:string are valid, so I can't see why this is wrong, plus there seems to be an inconsistency between max and min with hard-coded sequences.

Is this a bug, or am I using the functions in the wrong way?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2007
Added on Mar 28 2007
0 comments
4,883 views