I have an existing site which uses transforms and xml quite heavily, I have run into a problem with modifying this one section to contain descriptions, prior to this request it only contained links. I know this should be possible to add using transforms but I am not very good at them, would it be possible to output the desriptions using $response-write? my goal is to have the descriptions display directly underneath the links, the site is using active state perl and there are several transforms depending on which xml file it is processing. I realize this is a long post but I am trying to give enough information so that the problem is understood. Not being that good at regexes I am kind of puzzled how to accomplish my goal so that I get the description(s) my sub for tutorials first the tutorials sub..
sub mTutorials { if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /tempohelp/ +i ) { $str.=mLeftIndex(); my $xml = xmlFileData("Content", "tempotutorials.xml", "mTutorials() +"); if ($Request->item("DocID")->item()) { my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<tempo.*?<\/tempo>)/s; $str .= shadowBox("Tempo Tutorials", "<tutorials>".$1."</tutoria +ls>", ($g_docWidth/5*4-(2*$g_docSpace))); $xml =~ /(<general.*?<\/general>)/s; $str .= shadowBox("General PC Tutorials", "<tutorials>".$1."</tu +torials>", ($g_docWidth/5*4-(2*$g_docSpace))); } #$str.=mLeftIndex(); return $str; } else { $str.=mLeftIndex(); my $xml=xmlFileData("Content", "tutorials.xml", "mTutorials()"); if ($Request->item("DocID")->item()) { #my $id = $Request->item("DocID")->item(); $xml =~ /(<tut id=\"$id\".*?\/>)/s; $str .= $1; } else { $xml =~ /(<mlxchange.*?<\/mlxchange>)/s; $xml .=~/(<description.*?<\/description>)/s; $str .= shadowBox("MLXchange Tutorials &amp; Demos", "<tutorials +>".$1."</tutorials>", ($g_docWidth/5*4-(2*$g_docSpace))); $xml =~ /(<general.*?<\/general>)/s; $str .= shadowBox("General PC Tutorials", "<tutorials>".$1."</tu +torials>", ($g_docWidth/5*4-(2*$g_docSpace))); } return $str; } }
and finally an example xml file.
tutorials> <mlxchange> <tut id="15" treatment="external" src="http://www.mlxhelp.com/ +content/tutorials/mlx40/ActiveX_demo_mlx.htm" width="850" height="650 +" title="How to Install ActiveX Controls" /><description>This is a gr +eat tutorial watch it></description> </mlxchange> </tutorials>
as for transforms there are a total of 11 xsl files so I am not sure if posting them would be all that helpful, since it should be do-able using code, the site is using a here-doc. say I add the description tags above to my xml file, I am not sure how to get the contents of the description tag and the contents of the mlxchange tags to both display, there is a function called shadowbox which takes as its argument the title, the <tag>$whatever</tag> and docheight/docspace as arguments, what I really want is to stuff some other data in that box as $2 but I am not sure how to assign it properly, as I stated prior I am terrible at understanding regex. I guess I could assign a variable to the description regex as a placeholder then maybe concatenate the 2 values so that I get what I am after? <link> followed by description.. its hard to explain how this is setup, its a mess but unfortunately I am stuck with it. <code> $xml =~/(<description.*?<\/description>)/s;

In reply to how to add descriptions? by learn2earn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.