midasxl's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
193 (0.09 per day)
Joined:
03-December 08
Profile Views:
7,366
Last Active:
User is offline Aug 05 2014 07:03 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0

Latest Visitors

Icon   midasxl has not set their status

Posts I've Made

  1. In Topic: Mapping in an XSL transformation file - Please explain

    Posted 5 Aug 2014

    Ahh, yes, you are correct. Here is the additional code which will make things more concise:

    <xsl:variable name="status">
    <xsl:value-of select="/TARGET_STATUS/text()"/><!-- taken from the XML file -->
    </xsl:variable>
    <incident:status>
    <xsl:value-of select="document('')/*/status:map/entry[@key=$status]"/>
    </incident:status>
    
    


    So, let's say the XML node for /TARGET_STATUS/ has a value of "Open". This value would be compared to the data in the <status:map> node in the XSL file, and it would be converted to "Acknowledged".

    Makes sense to me, thanks for pointing me in the right direction!
  2. In Topic: XmlSearch for node with specific attribute value; add child element

    Posted 24 Apr 2014

    I am certainly trying everything. So far dead ends at each attempt. It's probably simple, I just need to wrap my head around it. So let's recap. Here is a sample of the xml I am dealing with:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="blog.xsl"?>
    <demoChanges>
    	<entry ID="212332">
    		<heading>Test</heading>
    		<descr>&lt;p&gt;Test&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>212332</id>
    		<comments/>
    	</entry>
    	<entry ID="43235">
    		<heading>Test</heading>
    		<descr>&lt;p&gt;&lt;br /&gt;Test&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>43235</id>
    		<comments/>
    	</entry>
    	<entry ID="740515">
    		<heading>New</heading>
    		<descr>&lt;p&gt;New&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>740515</id>
    		<comments/>
    	</entry>
    </demoChanges>
    
    


    Using ColdFusion I read the file in, parse it, and then locate the exact entry node that has the id attribute that matches the number passed in from the form scope.

    <cffile action="read" file="/path/to/the/blog.xml" variable="xmlFile">
    
    <cfset myXml = XmlParse(xmlFile)>
    
    <cfset myNode = XmlSearch(myXml, "demoChanges/entry[@ID=#threadid#]") />
    
    


    Dumping #myNode# to the page shows me the correct xml node that I am looking for (see array.jpg).

    There is a child element within this entry node called "comments". (see array2.jpg). Now that I have identified the correct entry node, I want to now use that and target the "comments" child element and add an element called "comment"

    The end result would look something like this (see the entry node with id="740515"):

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="blog.xsl"?>
    <demoChanges>
    	<entry ID="212332">
    		<heading>Test</heading>
    		<descr>&lt;p&gt;Test&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>212332</id>
    		<comments/>
    	</entry>
    	<entry ID="43235">
    		<heading>Test</heading>
    		<descr>&lt;p&gt;&lt;br /&gt;Test&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>43235</id>
    		<comments/>
    	</entry>
    	<entry ID="740515">
    		<heading>New</heading>
    		<descr>&lt;p&gt;New&lt;/p&gt;</descr>
    		<author>Mark</author>
    		<date>April 24, 2014</date>
    		<cert>Mark</cert>
    		<draft>no</draft>
    		<id>740515</id>
    		<comments>
                        <comment>Comment Text information goes here.</comment>
                    </comments>
            </entry>
    </demoChanges>
    
    


    I'm trying something like this:

    <cfset myXml.demoChanges.entry[which one?].comments.XmlChildren = XmlElemNew(myXml,"comment")>
    <cfset myXml.demoChanges.entry[which one?].comments.comment.xmltext = #formThreadDescr#>
    
    


    As you can see my problem ( I think ) is that I do not know how to target the entry that has the attribute id value I'm looking for. Now, I know I have identified that node using XmlSearch, but the result is an array, so I cannot use that in the <cfset>. For example, this does not work:

    <cfset myXml.myNode.comments.XmlChildren = XmlElemNew(myXml,"comment")>
    
    


    It errors out on the 'myNode' part saying you cannot use an array in the dot notation.

    I will continue to research, but if anyone reads this and has any ideas, I will be very grateful for your time and assistance.

    Thanks!
  3. In Topic: XmlSearch for node with specific attribute value; add child element

    Posted 23 Apr 2014

    Craig328,
    Thanks for your response!

    This line:

    <cfset myNode.comment = XmlElemNew(myXml, "comment")>
    


    Throws this error:

    You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members.

    XmlSearch returns an array, so perhaps I need to use array functions to add elements?
  4. In Topic: Character used as javascript separator. What is it?

    Posted 9 Oct 2013

    View PostCraig328, on 09 October 2013 - 09:23 AM, said:

    Hm. If it evaluated to a comma then you'd think you should be seeing ",light,".


    I do get ",light," when I alert the resultsArr. Then after the pop I alert again and get ",light". Then the code proceeds to trim the first character (the remaining comma).

    $.trim(resultsArr[0])
    
    


    Why all the trouble? Why not just return "light" in the first place??? This is legacy code by the way.

    Thanks!
  5. In Topic: Character used as javascript separator. What is it?

    Posted 9 Oct 2013

    Hello and thanks for youre time. I have a quick question regarding a strange character used as a separator in javascript.

    Coldfusion returned to an ajax block:
    <cfoutput>:-:</cfoutput>
    <cfoutput>#session.themeColor#</cfoutput>
    <cfoutput>:-:</cfoutput>
    
    


    Javascript which consumes the callback (partial):
    success: function(results){
    var resultsArr = results.split(":-:");
    resultsArr.pop();
    }
    
    


    Let's say the #session.themeColor# holds the value of "light".

    I dumped resultsArr and got ",light,"

    After the pop(), the last item in the array was removed and I got ",light"

    So the ":-:" resolves to a comma??? I've never seen this before, so I'm just looking to learn about this one.

    Any guidance will be greatly appreciated as always!

    Thanks!

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

midasxl hasn't added any friends yet.

Comments

midasxl has no profile comments yet. Why not say hello?