EscapeTool not working

lauren.fraser's Avatar

lauren.fraser

15 Jul, 2014 07:26 PM

I'm sure there's an error in my code, but I'm just not seeing it.
Below is my velocity code:

#set ( $docs = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
#set ( $docSD = $docs.getChild("system-data-structure") )
#set ( $docInfo = $docSD.getChild("doc-info") )
#set ( $docsFirstName = $docInfo.getChild("firstName") ) 
#set ( $docsLastName = $docInfo.getChild("lastName") ) 
#set ( $docsDegree = $docInfo.getChild("degree") ) 
#set ( $docsGender = $docInfo.getChild("gender") )
#set ( $docsIntro = $docInfo.getChild("intro") )
#set($docSpecialty=$_XPathTool.selectNodes($docInfo, "Specialties/primary-specialty[. != '']")) 

<div class="top-Find-Doctor-container cf">
                    <div class="Find-Doctor-left">
                        <h1>Find A Doctor</h1>
                        <h2>$_EscapeTool.xml($docsFirstName.value) $_EscapeTool.xml($docsLastName.value), $_EscapeTool.xml($docsDegree.value)</h2>
                        <span>$_EscapeTool.xml($docSpecialty.value)</span>
                        <p>
                           $_EscapeTool.xml($docsIntro.value) 
                       </p>
                    </div>

And the associated xml:

<system-data-structure>
<doc-info>
<firstName>Brent</firstName>
<lastName>Bartgis</lastName>
<degree>DO</degree>
<gender>M</gender>
<intro>General surgeon Brent Bartgis, D.O., is board certified in surgery. His practices and procedures include general surgery, diagnostic evaluation and operative therapy of urgent and general surgical problems, minimally invasive surgery, and flexible endoscopy.</intro>
<Specialties>
<primary-specialty>General Surgery</primary-specialty>
<ps-board-cert>Board Certified</ps-board-cert>
<secondary-specialty/>
<ss-board-cert/>
<as-specialty/>
<as-board-cert/>
</Specialties>
  1. 1 Posted by Ryan Griffith on 15 Jul, 2014 07:44 PM

    Ryan Griffith's Avatar

    Hi Lauren,

    Just to clarify, are you referring to the following line in particular?

    <span>$_EscapeTool.xml($docSpecialty.value)</span>
    

    If so, the issue is that you are setting $docSpecialty to the result of an XPathTool.selectNodes call, which returns an element array and not a single element. In this case, $docSpecialty.value does not exist.

    Are you only looking to grab the primary specialty element? If so, I would suggest either using XPathTool.selectSingleNode($docInfo, "Specialties/primary-specialty") or $docInfo->getChild("Specialty").getChild("primary-specialty") to obtain the primary specialty. This way, if the value is empty, the Escape Tool won't fail, it will just output an empty string.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by lauren.fraser on 15 Jul, 2014 09:02 PM

    lauren.fraser's Avatar

    Ryan,

    Actually none of it is outputting. I get this when I try to view the page:

  3. Support Staff 3 Posted by Tim on 15 Jul, 2014 09:06 PM

    Tim's Avatar

    Hi Lauren,

    The XML you attached in your description doesn't appear to match what you are doing in your Format. For example, the first line of your Format is assuming that you are transforming an Index Block:

    #set ( $docs = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
    
    However, the XML appears to be output from a Page:
    <system-data-structure>
    <doc-info>
    <firstName>Brent</firstName>
    <lastName>Bartgis</lastName>
    <degree>DO</degree>
    <gender>M</gender>
    <intro>General surgeon Brent Bartgis, D.O., is board certified in surgery. His practices and procedures include general surgery, diagnostic evaluation and operative therapy of urgent and general surgical problems, minimally invasive surgery, and flexible endoscopy.</intro>
    <Specialties>
    <primary-specialty>General Surgery</primary-specialty>
    <ps-board-cert>Board Certified</ps-board-cert>
    <secondary-specialty/>
    <ss-board-cert/>
    <as-specialty/>
    <as-board-cert/>
    </Specialties>
    
    Are you attaching your Format to a region on your Page that does not have an Index Block assigned to it?
  4. 4 Posted by lauren.fraser on 15 Jul, 2014 09:13 PM

    lauren.fraser's Avatar

    Aha! I didn’t have a block attached to that region at all! These pages were pulled in via web services and I hadn’t set up the configuration set to pull any blocks. Once I put an index block in that region it worked.

    Thanks!

  5. Support Staff 5 Posted by Tim on 15 Jul, 2014 09:16 PM

    Tim's Avatar

    Awesome! Glad we were able to help out. Take care!

  6. Tim closed this discussion on 15 Jul, 2014 09:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac