Suppose I have a text element whose length must be greater than 1 character.  I think an assert should be able to handle this, and there’s a string-length() function, so I wrote this for my xPath expression:

 

fn:string-length(.) > 1

 

But MBTK is telling me:

 

CTDX1100E : XSD: The attribute 'null' is not permitted

 

(This is, BTW, a less-than-helpful error message.)

 

 

I added it manually, like so:

 

                                                <xsd:element name="Body" type="xsd:string">

                                                            <xsd:annotation>

                                                                        <xsd:appinfo source="http://www.ogf.org/dfdl/">

                                                                                    <dfdl:assert message="The length of the body must be more than 1 character">

                                                                                                { fn:string-length(.) > 1 }

                                                                                    </dfdl:assert>

                                                                        </xsd:appinfo>

                                                            </xsd:annotation>

                                                </xsd:element>

 

And MBTK gave me this error:

 

CTDV1493E : XPath expression '{ fn:string-length(.) > 1 }' contains a path expression that does not resolve to an element in the schema: 'Found  ">" at line 1, column 23. Expected one of  "}" "or" "and" "*" "div" "idiv" "mod" "eq" "ne" "lt" "le" "gt" "ge" "[" "-" "+" "/"'. Element: #xmlns(p="http://fileid")xscd(/schemaElement::p:ImfMime/type::0/model::sequence/schemaElement::Body).

 

So this indicates it doesn’t like the “>” character.  So I changed it to &gt; but got the same message.

 

So am I implementing this wrong?  Or does MBTK not support this function?

 

Daffodil is also giving me an error:

 

Schema Definition Error: XPath Compilation Error: net.sf.saxon.trans.XPathException: XPath syntax error at char 20 in {fn:string-length(.) > 1}:

    Prefix fn has not been declared Schema context: element.Body. Location in file:/C:/Users/jgarriss/daffodil-0.8.1/bin/DetectImfMime.xsd

 

But this is a different issue, a namespace issue.  MBTK magically knows about the “fn:” namespace, but Daffodil doesn’t.  It’s not declared in the root element:

 

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema targetNamespace="http://fileid"

            xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:fmt="http://www.ibm.com/dfdl/GeneralPurposeFormat"

            xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:ns0="http://fileid"

            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 

Help!