Can default attibute values defined in xsd be referenced?
Altimes <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
I've been investigating using freemarker to generate code from XML embedded
in a source file. So far, so good. Then I thought I'd get a *little* bit
clevered and define attributes in the XSD with default values so that I
would not have to put them in the XML. I've checked the XSD and XML with
alternate tools, and they happily show me the default value of an attribute
that I do not supply in the XML (use="optional" default="123" in the xsd).
Sadly Freemarker has a bit of hissy fit with this. Throws the message
"Expecting a string, date or number here, Expression entry.@storeSize is
instead a freemarker.ext.dom.NodeListModel"
at me. A bit of investigation using entry.@storeSize?size (that I picked up
elsewhere in this forum, many thanks), showed 0 attributes. Which suggests
that the underlying parser is not working fully with the referenced XSD to
inject the missing nodes with their default values into the tree.
I know that I can use the FTL, default value process, but that duplicates
the location that the value is stored and that just feels wrong....
Easier to manage
<xsd:complexType name="fieldType">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element name="type" type="xsd:string"/>
<xsd:element name="storeName" type="xsd:string"/>
<xsd:element name="storeLimitName" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="storeSize" type="xsd:positiveInteger"
default="25" use="optional"/>
</xsd:complexType>
than to find multiple "25"s buried inside a couple of hundred lines of
template scripting for each occurence of the attribute.
Hopefully I am wrong and just need advice on the
freemarker.ext.dom.NodeModel API to call a like
...setUseDefault(true)
that I cannot find (or perhaps do not recognize).
TIA.
Alan.
--
View this message in context: http://freemarker.624813.n4.nabble.com/Can-default-attibute-values-defined-in-xsd-be-referenced-tp2283206p2283206.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first