Trouble with outputting content generated from a Data Def within a wrapping <system-region> tag
I have a "page" that when one edits, s/he enters data into a
Data Definition. I had a Format in Velocity that was to output,
using the entered data, and it worked well, except it wrapped it in
a system-region tag. I need this to be tagless (i.e., not XML
compliant).
I have reviewed
http://help.hannonhill.com/discussions/xslt-formats/15-trouble-with...
and learned some great things there, but it appears better suited
for static code entered as opposed to dynamically generated via a
Data Def. I attempted the solutions there with my instance, but
cannot seem to get it to work. So, I am wondering how to generate
output without tags from input generated by a Data Definition.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Charlie Holder on 25 Apr, 2012 01:12 PM
Hey James --
Can you paste the XML content that your block is generating and the format that you're using to transform it?
Feel free to make this thread private if you feel the need based on the data you'd be attaching.
Thanks.
3 Posted by James on 25 Apr, 2012 02:53 PM
Support Staff 4 Posted by Charlie Holder on 26 Apr, 2012 08:07 PM
Are you trying to use a Format in a region without a Block? Or is this Format parsing an actual Block asset?
What kind of Template are you using to output this information? Are you trying to output this as the only thing in the Template or is it contained within a larger page structure?
Cascade is going to publish XML compliant code, so if you don't provide a wrapping element that will be one reason for why it would want to wrap your output in a system tag.
So you have tried using the START-CODE and END-CODE tags and those do not seem to be working?
5 Posted by Johnson, James Arthur - johns2ja on 26 Apr, 2012 08:27 PM
The XML is generated by a Data Def tied to the Content Type. I then have a Format tied to the Configuration Set.
The template is just one line: <system-region name="DEFAULT"/>
I am trying to output this as the only thing.
I am getting an error that I don't have a wrapping element, but the file I am attempting to generate won't function properly if it is wrapped.
I changed the Template to use the following: <to-strip><!--#START-ROOT-CODE <system-region name=”DEFAULT”/> #END-ROOT-CODE--> </to-strip> and this did not work, either.
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
6 Posted by James on 02 May, 2012 12:44 PM
I have come up with a solution for a "tagless" .htaccess file (a page called . with extension of htaccess in Cascade). I had to put
before and
after the content within the xsl:template. The #ignore uses a # which is a comment in an .htaccess file. This is all done within a Template that looks like this:
Here's the XSLT Format:
7 Posted by James on 02 May, 2012 08:34 PM
While the XSLT solution works like a charm, I am working on a similar type of solution for another Format that generates a non-XML compliant file, but should use Velocity Script. The type of file does not have multi-line comments that I know of. Any suggestions on that?
8 Posted by James on 02 May, 2012 08:44 PM
Also noticed that the ignore:#END-ROOT-CODE line should have a # in front of it to work. For whatever reason, it did not render that way.
9 Posted by James on 02 May, 2012 08:50 PM
Charlie, sorry about all the messages, but in case someone else sees this, I want to ensure the XSLT htaccess solution is helpful. So, I have attached it in a file.
Support Staff 10 Posted by Ryan Griffith on 21 Jun, 2012 06:52 PM
Hi James,
I was going over some older discussions and noticed this one is still open. Were you able to get a Velocity Format equivalent to the XSLT working?
Please feel free to let us know if you have any other questions.
Thanks.
11 Posted by Johnson, James Arthur - johns2ja on 26 Jun, 2012 01:58 PM
I was unable to get the Velocity Format equivalent to work.
Support Staff 12 Posted by Ryan Griffith on 26 Jun, 2012 07:44 PM
James, my apologies I had not realized you were posting under two usernames.
Using the XML you posted previously, I made an attempt at creating a Velocity Format (see below) that mimics the XSLT you posted.
To set up, reuse the same set up as you described above but replace the XSLT Format with the Velocity Format below.
Please let me know how this works out.
Thanks.
Support Staff 13 Posted by Ryan Griffith on 17 Jul, 2012 06:51 PM
Hi James,
Just wanted to follow up to see if you had a chance to view my recent comment.
Please let us know if you have any questions.
Thanks.
14 Posted by Johnson, James Arthur - johns2ja on 17 Jul, 2012 07:24 PM
Ryan,
I hope to get to that either this week or next week. Thanks for following up!
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 15 Posted by Ryan Griffith on 25 Jul, 2012 06:38 PM
Hi James,
I wanted to follow up to see if you had a chance to look into my comment above and whether or not that helped you out.
Thanks.
16 Posted by Johnson, James Arthur - johns2ja on 25 Jul, 2012 07:03 PM
Ryan,
I modified my code to use the START CODE and ignore in the manner yours does and there is progress. However, it does not fully work as desired. Looking further into it, however, I have determined that this is a limitation of items outside of Cascade. The Configuration file generated by the Format is close to what I need, but cgi script used to process it is "too picky" without some further manual modifications of the Configuration file. This is a limitation of the cgi script. I would say this is closed since it appears I will have to come up with a different solution that works better with a Cascade implementation. Thanks for looking into it!
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 17 Posted by Ryan Griffith on 25 Jul, 2012 07:16 PM
Thank you for the followup, James.
Perhaps you could just host the static file within Cascade and publish it to the server? This would at least give you the benefits of user access/security and revisions.
18 Posted by Johnson, James Arthur - johns2ja on 25 Jul, 2012 07:18 PM
I could, but the Configuration file has items in it that have a 1:1 relationship with items on a form. I was generating 2 files (form and configuration) with one data def-driven base asset.
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 19 Posted by Ryan Griffith on 25 Jul, 2012 07:54 PM
Ah, true I forgot about that part.
What portion of the generated file does the CGI not like?
20 Posted by Johnson, James Arthur - johns2ja on 25 Jul, 2012 07:56 PM
Some of the spacing between items (above, below). The CGI is quite (too) picky.
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 21 Posted by Ryan Griffith on 25 Jul, 2012 08:00 PM
Would you be able to provide a working example and an example of what is being generated by the Format? Perhaps there is some tweaking that could be done to handle whitespace a bit better.
22 Posted by Johnson, James Arthur - johns2ja on 25 Jul, 2012 08:44 PM
Ryan,
The working example uses multiple folders, files, Blocks, and Formats - all generated by the folder-based Base Asset. Would it be most helpful to show the generated XML and the Formats for the various files and then send attachments of the files that are generated?
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 23 Posted by Ryan Griffith on 30 Jul, 2012 01:10 PM
Hi James,
Yes, if you could provide the following so I can try to tweak things in my local instance that would be great:
Thanks!
24 Posted by Johnson, James Arthur - johns2ja on 30 Jul, 2012 01:32 PM
Ryan,
###############################################################################################
Here is the XML:
###############################################################################################
<system-data-structure>
<block>
<content>
<system-data-structure>
<setup>
<formtitle>Test Form</formtitle>
<recipient>[email blocked]</recipient>
<subject>test</subject>
<functionality>
<value>Mailer</value>
</functionality>
<js/>
<css/>
<csv/>
<delimiter/>
<cfgpath/>
<cfg/>
</setup>
<textinputoptions>
<label>Enter a word</label>
<usethis>Yes</usethis>
<required>Yes</required>
<validation>None</validation>
</textinputoptions>
<textinputoptions>
<label>Enter a number</label>
<usethis>Yes</usethis>
<required>No</required>
<validation>Number</validation>
</textinputoptions>
<textareaoptions>
<label>Enter a thought</label>
<usethis>Yes</usethis>
<required>No</required>
<validation>None</validation>
</textareaoptions>
<checkboxoptions>
<label>Check these out</label>
<checkboxes>
<checkbox/>
<checkboxitem>Lions</checkboxitem>
</checkboxes>
<checkboxes>
<checkbox/>
<checkboxitem>Tigers</checkboxitem>
</checkboxes>
<checkboxes>
<checkbox/>
<checkboxitem>Bears</checkboxitem>
</checkboxes>
<usethis>Yes</usethis>
<required>No</required>
</checkboxoptions>
<checkboxoptions>
<label>Exclaim</label>
<checkboxes>
<checkbox/>
<checkboxitem>Oh</checkboxitem>
</checkboxes>
<checkboxes>
<checkbox/>
<checkboxitem>My!</checkboxitem>
</checkboxes>
<usethis>Yes</usethis>
<required>No</required>
</checkboxoptions>
<radiooptions>
<label/>
<radios>
<radio/>
<radioitem/>
</radios>
<usethis/>
<required/>
</radiooptions>
<dropdownoptions>
<label/>
<option/>
<option/>
<usethis/>
<required/>
</dropdownoptions>
<datepicker>
<label/>
<usethis/>
<required/>
</datepicker>
<htmlresponse>
<htmlpre>bravo!
<span style="white-space: pre;"> </span>
</htmlpre>
<htmlpost>well done....</htmlpost>
</htmlresponse>
</system-data-structure>
</content>
<path>/forms/test/testing/_cascade/doformdetail</path>
<site>JMU</site>
<name>doformdetail</name>
<display-name>DoForm Detail</display-name>
<title>DoForm Detail</title>
</block>
</system-data-structure>
###############################################################################################
Here is the Velocity Format:
###############################################################################################
<!--#START-ROOT-CODE
[system-view:internal]
#set($cfgname = $_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/setup/cfg').value)
#if($cfgname != '')
## do nothing
#else
#set($cfgname = "myform")
#end
<div style="background:#fffccc;border:2px solid #450084;padding:5px;">
<h2>***DEVELOPER NOTES:</h2>
<p>This will <b>not appear</b> in the published CFG file.</p>
<p>Per your specifications, this file should be named <b>$cfgname</b>.</p>
</div>
[/system-view:internal]
## DoForm Builder by James Arthur "Jamie" Johnson (johns2ja)
#set($csvname = $_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/setup/csv').value)
#if($csvname != '')
## do nothing
#else
#set($csvname = "data")
#end
#set($delimiter = $_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/setup/delimiter').value)
#if($delimiter != ',' or $delimiter != '~')
#set($delimiter = ',')
#end
#set($htmlpre = $_SerializerTool.serialize($_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/htmlresponse/htmlpre').value, true))
#set($htmlpost = $_SerializerTool.serialize($_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/htmlresponse/htmlpost').value, true))
#set( $functionality1 = 0)
#set( $functionality2 = 0)
#set( $functionvalues = $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/setup/functionality/value'))
#foreach($value in $functionvalues)
#if( $value.value == 'Mailer' )
#set( $functionality1 = 1 )
#end
#if( $value.value == 'Save-As' )
#set( $functionality2 = 1 )
#end
#end
#set($pipe = 'false')
##TEXT INPUT
#set($inputnum = 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/textinputoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $inputnum = $inputnum + 1 )
#if($node.getChild('required').value == 'Yes')
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE INPUT$inputnum
The text input field for $node.getChild('label').value is required.<br />
#end
#end
#end
##TEXT AREA
#set($textareanum = 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/textareaoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $textareanum = $textareanum + 1 )
#if($node.getChild('required').value == 'Yes')
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE TEXTAREA$textareanum
The textarea for $node.getChild('label').value is required.<br />
#end
#end
#end
##CHECKBOXES
#set($checkboxnum= 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/checkboxoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $checkboxnum= $checkboxnum+ 1 )
#if($node.getChild('required').value == 'Yes')
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE CHECKBOX$checkboxnum
The checkboxes for $node.getChild('label').value are required.<br />
#end
#end
#end
##DROPDOWNS
#set( $dropdownnum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/dropdownoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $dropdownnum= $dropdownnum+ 1 )
#if($node.getChild('required').value == 'Yes')
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE OPTIONS$dropdownnum
The dropdown menu for $node.getChild('label').value is required.<br />
#end
#end
#end
##RADIO
#set( $radionum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/radiooptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $radionum = $radionum + 1 )
#if($node.getChild('required').value == 'Yes')
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE RADIO$radionum
The radio buttons for $node.getChild('label').value are required.<br />
#end
#end
#end
##DATEPICKER
#set( $datenum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot, '/system-data-structure/block/content/system-data-structure/datepicker'))
#if($node.getChild('usethis').value == 'Yes')
#set( $datenum = $datenum + 1 )
#if($node.getChild('required').value == 'Yes' )
#if($pipe == 'false')
#set($pipe = 'true')
#else
|
#end
REQUIRE DATE$datenum
The date for $node.getChild('label').value are required.<br />
#end
#end
#end
## RECIPIENT(S)
#if( $functionality1 == 1 )
|<br />
MAIL-TO
#set( $recipients = $_XPathTool.selectNodes($contentRoot, '/system-data-structure/block/content/system-data-structure/setup/recipient'))
#set($totalrecipients = 0)
#foreach( $x in $recipients )
#set($totalrecipients = $foreach.count)
#end
#foreach( $recipient in $recipients )
$recipient.value#if($foreach.count != $totalrecipients),#end
#end
$_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/block/content/system-data-structure/setup/subject').value<br />
#outputdata('<br />')
<br />
#end
##HTML RESPONSE
|
RESPOND HTML
#if($htmlpre)
$htmlpre
#end
<br />
<div style="color:black">
<p>You submitted the following:</p>
#outputdata('<br />')
<br />
</div>
#if($htmlpost)
$htmlpost
#end
<br />
## SAVING
#if( $functionality2 == 1 )
|<br />
SAVE-AS ${csvname}<br />
#outputdata($delimiter)
#end
##OUTPUT MACRO
#macro(outputdata $char)
#set($outputfinal = '')
##TEXT INPUT
#set($inputnum = 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/textinputoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $inputnum = $inputnum + 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|input"+$inputnum+"|"+$char)
#end
#end
##TEXT AREA
#set($textareanum = 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/textareaoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $textareanum = $textareanum + 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|textarea"+$textareanum+"|"+$char)
#end
#end
##CHECKBOXES
#set($checkboxnum= 0)
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/checkboxoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $checkboxnum= $checkboxnum+ 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|checkbox"+$checkboxnum+"|"+$char)
#end
#end
##DROPDOWNS
#set( $dropdownnum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/dropdownoptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $dropdownnum= $dropdownnum+ 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|options"+$optionsnum+"|"+$char)
#end
#end
##RADIO
#set( $radionum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot,'/system-data-structure/block/content/system-data-structure/radiooptions'))
#if($node.getChild('usethis').value == 'Yes')
#set( $radionum = $radionum + 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|radio"+$radionum+"|"+$char)
#end
#end
##DATEPICKER
#set( $datenum = 0 )
#foreach($node in $_XPathTool.selectNodes($contentRoot, '/system-data-structure/block/content/system-data-structure/datepicker'))
#if($node.getChild('usethis').value == 'Yes')
#set( $datenum = $datenum + 1 )
#if($char != ',' and $char !='~') ## not SAVE-AS
#set($outputfinal = $outputfinal + $node.getChild('label').value+": ")
#end
#set($outputfinal = $outputfinal + "|date"+$datenum+"|"+$char)
#end
#end
#set($outputfinal = $outputfinal + "EOF")
#set($eof = $char + "EOF")
$_StringTool.substringBefore($outputfinal, $eof)
#end
###############################################################################################
Here is the output (lots of extra spacing):
###############################################################################################
REQUIRE INPUT1
The text input field for Enter a word is required.<br />
|<br />
MAIL-TO
[email blocked] test<br />
Enter a word: |input1|<br />Enter a number: |input2|<br />Enter a thought: |textarea1|<br />Check these out: |checkbox1|<br />Exclaim: |checkbox2|
<br />
|
RESPOND HTML
<br />
<div style="color:black">
<p>You submitted the following:</p>
Enter a word: |input1|<br />Enter a number: |input2|<br />Enter a thought: |textarea1|<br />Check these out: |checkbox1|<br />Exclaim: |checkbox2|
<br />
</div>
<br />
###############################################################################################
And here is what it should look like:
###############################################################################################
REQUIRE INPUT1
The text input field for Enter a word is required.<br />
|
MAIL-TO [email blocked] test
Enter a word: |input1|
Enter a number: |input2|
Enter a thought: |textarea1|
Check these out: |checkbox1|
Exclaim: |checkbox2|
|
RESPOND HTML
<div style="color:black">
<p>You submitted the following:</p>
Enter a word: |input1|<br />
Enter a number: |input2|<br />
Enter a thought: |textarea1|<br />
Check these out: |checkbox1|<br />
Exclaim: |checkbox2|
<br />
</div>
<br />
###############################################################################################
###############################################################################################
James "Jamie" Johnson, BBA, MA, A+, ACHDS, HDA, HDM, MOS, W3S/HTML
JMU Information Technology Web Developer
Browser Detection and Test
"Test everything. Hold on to the good."
1 Thessalonians 5:21
Support Staff 25 Posted by Ryan Griffith on 30 Jul, 2012 03:08 PM
James,
From what I am reading on the Velocity Wiki, whitespace control within the language is still on ongoing debate; however, this page does offer a few "workarounds" to remove the whitespace. The most common workarounds are to remove all indentation and unnecessary line breaks, and adding an empty comment
##to the end of lines that do require a line break (or end up adding an extra line).That said, one downside to this is that it leaves the velocity very difficult to read. The page I linked to above) offers a few suggestions and this stackoverflow page offers a few additional methods to at least attempt to add some spacing to the Format to make it a little easier to read. Still far from clean, unfortunately.
The following Format seemed to remove all extra line breaks and spacing using the XML you provided; however, as you will see, it's pretty ugly. I also had to remove unnecessary trailing spaces from a large number of lines:
Support Staff 26 Posted by Ryan Griffith on 06 Aug, 2012 07:45 PM
Hi James,
Just wanted to follow up to see if you had a chance to view my recent comment.
Please let us know if you have any questions.
Thanks.
Ryan Griffith closed this discussion on 20 Aug, 2012 12:55 PM.