Format for XML File
I have imported this file into Cascade and am wanting to make a velocity format that reads it and displays content. I am unsure how to begin with my variables. I am wanting to do something like this...
#set ($classes = $_XPathTool.selectNodes($contentRoot, "//system-block/system-data-structure"))
#foreach($class in $classes)
#set ( $name = $class.getChild("CRSE_NUMB").value)
#set ( $number = $class.getChild("CRSE_TITLE").value)
#set ( $number = $class.getChild("CRSE_DESC").value)
- ART_Courses_Extract_022715.xml 49.4 KB
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
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
1 Posted by Ryan Griffith on 02 Mar, 2015 08:38 PM
Hi Graham,
Was this XML file created as an XML Block by chance? If so, are you applying it directly to a region or using a Block chooser within a Data Definition?
The following may change based on your answer, but here's my initial thought as to what should work:
Note: because you have multiple
COLUMN
elements within eachROW
, using the XPath Tool would be your best best so you can filter by the@NAME
attribute.Please let me know if you have any questions.
Thanks!
2 Posted by Graham Lewis on 02 Mar, 2015 08:55 PM
You, sir, are the bomb.com haha
That worked perfectly.
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
3 Posted by Ryan Griffith on 02 Mar, 2015 09:03 PM
Thank you for following up, Graham. I am glad to hear the proposed Velocity code did the trick for you.
I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.
Have a great day!
Ryan Griffith closed this discussion on 02 Mar, 2015 09:03 PM.
Graham Lewis re-opened this discussion on 02 Mar, 2015 09:04 PM
4 Posted by Graham Lewis on 02 Mar, 2015 09:04 PM
Sounds good - thanks!
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Ryan Griffith closed this discussion on 02 Mar, 2015 09:19 PM.
Graham Lewis re-opened this discussion on 03 Mar, 2015 04:12 PM
5 Posted by Graham Lewis on 03 Mar, 2015 04:12 PM
If I wanted to display text that is between ( ), how would I do that? I would just want to display Printmaking.
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
6 Posted by Ryan Griffith on 03 Mar, 2015 07:22 PM
Hi Graham,
There are a couple of ways I can think of to accomplish this, both of which assume you just want the text within the first matching parentheses.
When you have a moment, try the following and let me know how it works out:
The first splits by the
(
and)
and will give you the first text that appeared within the parentheses. The second will locate the indexes of the first(
and)
and perform a substring to get the text.Please let me know if you have any questions.
Thanks!
7 Posted by Graham Lewis on 04 Mar, 2015 02:43 PM
Ryan,
That worked. An issue I am running in to is I have two blocks being called on the same page, but in two different DD groups. One is for "programs" and one is for "courses" - they both have the same structure //results/rows and I am thinking they are getting mixed up - two of my tests works, but one doesn't. On the one that doesn't - if the programs xml displays correctly, the courses doesn't and if the courses work the programs don't. lol.
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
8 Posted by Ryan Griffith on 04 Mar, 2015 03:15 PM
Thank you for following up, Graham. I am glad to hear the my suggestions worked.
In this case, I would suggest being more specific with the XPath that is used to grab the classes to target the correct Block. Specifically, using
//RESULT
will get allRESULT
elements at any level.Please let me know if you have any questions.
Thanks!
9 Posted by Graham Lewis on 04 Mar, 2015 03:23 PM
So maybe - #set ($data = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure/degrees/results/row")) ?
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
10 Posted by Ryan Griffith on 04 Mar, 2015 03:35 PM
Is
degrees
a block chooser? If so, I think it would be more like:Note: I am pretty sure the element name is case sensitive, so if
RESULTS
andROW
are all caps in the XML Block, you'll want to repeat that in your XPath.Please let me know if you have any questions.
Thanks!
Ryan Griffith closed this discussion on 11 Mar, 2015 08:33 PM.