[CJ-dev] commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet
Brought to you by:
johnqueso
From: John C. <joh...@co...> - 2004-03-16 22:56:57
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv555/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet Modified Files: OplXsdPlugin.jelly OplNodeParserPlugin.vm Log Message: added use-body attribute to the OplAttributeTag class, to support pulling attribute values directly from the element's body content. Index: OplXsdPlugin.jelly =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplXsdPlugin.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplXsdPlugin.jelly 8 Mar 2004 14:36:34 -0000 1.1 +++ OplXsdPlugin.jelly 16 Mar 2004 22:47:33 -0000 1.2 @@ -42,35 +42,37 @@ </if> <forEach var="method" items="${class.methods}"> <set var="attrTag" value="${method.getTagByName('opl.attribute')}"/> - <if test="${attrTag != null}"> - <x:element name="xs:attribute"> - <x:attribute name="name">${attrTag.getNamedParameter('name')}</x:attribute> - <set var="requiredVal" value="${attrTag.getNamedParameter('required')}"/> - <choose> - <when test="${requiredVal != null}"> - <choose> - <when test="${requiredVal == 'false'}"> - <x:attribute name="use">optional</x:attribute> - </when> - <otherwise> - <x:attribute name="use">required</x:attribute> - </otherwise> - </choose> - </when> - <otherwise> - <x:attribute name="use">optional</x:attribute> - </otherwise> - </choose> - <set var="typeVal" value="${attrTag.getNamedParameter('type')}"/> - <choose> - <when test="${typeVal != null}"> - <x:attribute name="type">xs:${typeVal}</x:attribute> - </when> - <otherwise> - <x:attribute name="type">xs:string</x:attribute> - </otherwise> - </choose> - </x:element> + <if test="${attrTag.getNamedParameter('use-body') == 'false'}"> + <if test="${attrTag != null}"> + <x:element name="xs:attribute"> + <x:attribute name="name">${attrTag.getNamedParameter('name')}</x:attribute> + <set var="requiredVal" value="${attrTag.getNamedParameter('required')}"/> + <choose> + <when test="${requiredVal != null}"> + <choose> + <when test="${requiredVal == 'false'}"> + <x:attribute name="use">optional</x:attribute> + </when> + <otherwise> + <x:attribute name="use">required</x:attribute> + </otherwise> + </choose> + </when> + <otherwise> + <x:attribute name="use">optional</x:attribute> + </otherwise> + </choose> + <set var="typeVal" value="${attrTag.getNamedParameter('type')}"/> + <choose> + <when test="${typeVal != null}"> + <x:attribute name="type">xs:${typeVal}</x:attribute> + </when> + <otherwise> + <x:attribute name="type">xs:string</x:attribute> + </otherwise> + </choose> + </x:element> + </if> </if> </forEach> </x:element> Index: OplNodeParserPlugin.vm =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplNodeParserPlugin.vm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- OplNodeParserPlugin.vm 12 Mar 2004 19:46:56 -0000 1.4 +++ OplNodeParserPlugin.vm 16 Mar 2004 22:47:34 -0000 1.5 @@ -22,11 +22,14 @@ ${plugin.buildImplementsClause($class)} { #foreach($method in $class.methods) - #if($method.getNamedParameter("opl.attribute", "name")) + #if(!$method.getNamedParameter("opl.attribute", "use-body")) + #if($method.getNamedParameter("opl.attribute", "name")) private static final String ${plugin.getAttributeConstant($method)} = "${method.getNamedParameter("opl.attribute", "name")}"; + #end #end #end + private ${class.fullyQualifiedName} instance = new ${class.fullyQualifiedName}(); #if($plugin.shouldGenerateLocalPropertyContainer($class)) private Properties properties = new Properties(); @@ -52,6 +55,7 @@ protected final void doBeforeChildren(ElementInfo info) throws ParseException{ #foreach($method in $class.methods) + #if(!$method.getNamedParameter("opl.attribute", "use-body")) #if($method.getNamedParameter("opl.attribute", "before-children") == "true") try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) @@ -110,15 +114,22 @@ } } #end + #end #end } protected final void doAfterChildren(ElementInfo info, String bodyText) throws ParseException{ #foreach($method in $class.methods) - #if($method.getNamedParameter("opl.attribute", "before-children") == "false") + #if($method.getNamedParameter("opl.attribute", "before-children") == "false" || $method.getNamedParameter("opl.attribute", "use-body") == "true") try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) - String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + + #if($method.getNamedParameter("opl.attribute", "use-body") == "true") + String ${attrName} = bodyText; + #else + String ${attrName} = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + #end + #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") |