I have defined the xml as below with all information in it.
<application>
<name>CRUD Generator</name>
<author>User 1</author>
<version>Beta</version>
<description>Generate ColdFusion Components based on Database Tables</description>
<menucontributions >
<contribution target="rdsview" >
<menu name="CFC Generator">
<action name="Create CFC" handlerid="startCRUD" showResponse="no">
<input name="location" default="paths" label="Enter destination" tooltip="Location where generated CFCs will be stored" type="projectdir" required="true"/>
<input name="generateService" label="Generate Service?" tooltip="Generate service to be consumed" type="boolean" checked="true"/>
<input name="scriptbased" label= "Script CFC?" type="boolean" />
</action>
</menu>
</contribution>
</menucontributions>
<!-- Define Handlers-->
<handlers>
<handler id="startCRUD" type="CFM" filename="cfcGen.cfm" />
</handlers>
<rdsview>
<database name="dbo.AcademicDbo">
<table name="abc">
<fields>
<field name="id" type="int" length="" nullallowed="NO" primarykey="id"/>
<field name="CoreCode" type="varchar" length="50" nullallowed="NO" primarykey="id"/>
<field name="CoreDescription" type="varchar" length="250" nullallowed="NO" primarykey="id"/>
<field name="SubCriteriaID" type="int" length="" nullallowed="NO" primarykey="id"/>
<field name="modifiedby" type="int" length="" nullallowed="YES" primarykey="id"/>
<field name="insertby" type="int" length="" nullallowed="YES" primarykey="id"/>
<field name="modifieddate" type="datetime" length="" nullallowed="NO" primarykey="id"/>
<field name="insertdate" type="datetime" length="" nullallowed="NO" primarykey="id"/>
<field name="iLastActionBy" type="int" length="" nullallowed="YES" primarykey="id"/>
<field name="dLastActionDate" type="datetime" length="" nullallowed="YES" primarykey="id"/>
<field name="iLastActionBranch" type="int" length="" nullallowed="YES" primarykey="id"/>
</fields>
</table>
</database>
</rdsview>
</application>
now i have the cfc but i am having some trouble finding the xml and create a working code so my components can find its value but it is not working, i am definately missing some pieces here, my xml knowlledge is not good so having hard time doing it, i already tried 3 hours but none came out, now i seek guidance
<cffunction name="parseIDEEventInfo" returntype="struct" access="public">
<cfargument name="xml" type="string" required="true" />
<cfset extxml= xmlParse(ARGUMENTS.xml)>
<cfset extsys = {}>
<cfset dsarr=ArrayNew(1)>
<cfset extxmlinput = xmlSearch(extxml, "/event/user/input")>
<cfset extxmltable ="">
<!--<cfset extsys.input = {}>-->
<cfloop index="i" from="1" to="#arrayLen(extxmlinput)#" >
<cfset StructInsert(extsys.input,"#extxmlinput[i].xmlAttributes.name#","#extxmlinput[i].xmlAttributes.value#")>
</cfloop>
<cfdump var="#extxml#">
<cfset dsarr=xmlSearch(extxml, "/rdsview/database")>
<cfdump var="#dsarr#">
<cfset extsys.input.datasource = dsarr[1].XMLAttributes.name>
<cfdump var="#extxml#">
<!---<cfset extsys.input.database = getDBType(extsys.input.datasource)>--->
<cfset extsys.table = []>
<cfset extxmltable = xmlSearch(extxml, "/database/table")>
<cfloop index="i" from="1" to="#arrayLen(extxmltable)#">
<cfif(find('.',extxmltable[i].xmlAttributes.name))>
<cfset extxmltable[i].xmlAttributes.name = getToken(extxmltable[i].xmlAttributes.name, 2, '.')>
</cfif>
<cfset table = StructNew()>
<cfset table.name=extxmltable[i].xmlAttributes.name>
<cfset table.table=extxmltable[i].xmlAttributes.name>
<cfset table.file=tCase(extxmltable[i].xmlAttributes.name)>
<cfset table.field=[]>
<cfif( StructkeyExists(extsys.input,"fromfb"))>
<cfset table.field = getColumns(extxmltable[i].fields.field,"true")>
<cfelse>
<cfset table.field = getColumns(extxmltable[i].fields.field,"false")>
</cfif>
<cfset table.key = []>
<cfset table.foreign = []>
<cfloop index="j" from="1" to="#arrayLen(table.field)#">
<cfif(table.field[j].isPrimaryKey)>
<cfset arrayAppend(table.key, table.field[j])>
</cfif>
<cfif table.field[j].isForeignKey >
<cfset arrayAppend(table.foreign, table.field[j])>
</cfif>
</cfloop>
<cfset arrayAppend(extsys.table, table)>
</cfloop>
<!---- return success ---->
<cfreturn extsys />
</cffunction>
the function which i am modifying to do it and make it working order
You are searching for /rdsview/database
in your XML document, but the top level of the doc is applicaction
.
There are two relevant strategies here. First: just get yer search string correct, it would be: /applicaction/rdsview/database
. This returns results from your xmlSearch
.
Secondly if you just wanted the nodes matching a subhierarchy of /rdsview/database
anywhere in the doc (not necessarily immediately within application
) you could search for //rdsview/database
.
However in this case it's the former you want to be doing, given /rdsview/database
only appears in one place in the hierarchy in the first place.
I have found http://zvon.org/comp/r/tut-XPath_1.html#Pages~List_of_XPaths to be a good reference for explaining how XPath strings work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.