XPATH 2.0 "FOTY0012: The node has no typed value"

I have a simple input XML file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rootelement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="index.xsd">

Open in new window

and a simple schema file to go with it index.xsd:
<?xml version='1.0' encoding='utf-8' ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="rootelement" type="RootType"/>

  <xs:complexType name="RootType">
      <xs:element name="compound" type="CompoundType"/>

  <xs:complexType name="CompoundType">
      <xs:element name="name" type="xs:string"/>
      <xs:element name="member" type="MemberType"/>

  <xs:complexType name="MemberType">
      <xs:element name="name" type="xs:string"/>


Open in new window

and a simple XSLT 2.0 transformation file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  <xsl:template match="/">
    <xsl:apply-templates select="rootelement" />
  <xsl:template match="rootelement">
    <xsl:copy-of select="." />
    <xsl:value-of select="." />


Open in new window

which when I run the transform on the input XML file, I get the error:

"FOTY0012: The node <rootelement> has no typed value"

when it hits the line: <xsl:value-of select="." />

Is there a way I can modify the schema file index.xsd so I don't get this error?

The closest to an explanation I could find is:
XML Path Language (XPath) 2.0
2.5.2 Typed Value and String Value


However, I'm still not clear on why it doesn't just grab the text and return it, like XPATH 1.0 does, or like it does if I don't supply the schema.
deleydSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
The problem is that your output is no  XML
(you failed to tell us how you run the XSLT actually)

but the copy-of copies does a deep copy of the rootelement, so you open en close a rootelement named <rootelement> in your output
after that you do a value-of, copying all the text nodes from your source, after the root element has been closed
You don't need to change the schema (the source is valid against the schema), you need to change the XSLT
Gertone (Geert Bormans)Information ArchitectCommented:
Well, partially ignore the above, it is true that the result is not well formed XML, but the error happens before serialization

xsl:value-of does atomisation
and the schema dictates that <rootelement> only has element content only
see here
that is done by implicitely executing fn:data()

I don't think you should change the schema... the content of your root is element only, so says the schema
you simply should not pass a value-of on the node with element only content

you could do this
        <xsl:value-of select=".//text()" />
 which has the same effect in the XSLT2
but then the atomisation does not break on the untyped node

If you would change the schema, all you can do is set the content type to mixed
    <xs:complexType name="RootType" mixed="true">
then the XSLT won't break
but you make the not significant whitespace into significant whitespace... your choice

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
Both suggested solutions
- change the value-of select attribute
- set the complex type of the document root to mixed
work on both Saxon EE and the Altova engine
deleydSoftware EngineerAuthor Commented:
Thank you that's exactly what I needed to know.

(I suspect this may be code that was originally XSLT 1.0 ported to 2.0 and then handed to me.)
Gertone (Geert Bormans)Information ArchitectCommented:
yes, porting 1.0 code to 2.0 has a lot of potential side effects
it could take a fair amount of rework, specially because of the type system
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.