Jump to content

abartsch

Members
  • Posts

    9
  • Joined

  • Last visited

abartsch's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I'm trying to set the height of my iframe according to its content but it didn't work so far. I was googling around and found some hints regarding div height to set to 100% but it could also not help. The content of the iframe is automatically filled by an PHP script which calls an XML translation. The generated HTML contains again a number of divs which are formatted via CSS. Formatting works fine but the height is limited to a default minimum size. Here comes global structure of my HTML page: <body><div id="container"> <div id="header"> </div> <div id="logo"> </div> <div id="topNavi"> <div id="topNaviLeft"> </div> <div id="topNaviRight"> </div> </div> <div id="center"> <div id="centerLeft"> <div id="centerLeftNavi"> </div> </div> <div id="centerRight"> <iframe name="iframeContent" width="856"></iframe> </div> </div> <div id="footer"> </div></div></body> I would appreciate any assistance!
  2. Thanks, boen_robot! We installed the new PHP version 5.4.5 and are going to install the new libxml2 version 2.8.0 soon. Anyway, I found a workaround i.e. now I save the modified XML file first, open the saved XML file and do the transformation finally. Here is the modified code snippet: $xml = new DOMDocument; $xml->formatOutput = true; $xml->load("xml/$hostname.log.xml"); $elements = $xml->getElementsByTagName("*"); foreach($elements as $element) { $type = $element->getAttribute('type'); $title = $element->getAttribute('title'); if($type == 'comment' or $title == 'Installed Packages') { foreach($element->childNodes as $item) { if($item->nodeType == 4) // XML_CDATA_SECTION_NODE { $cdataWrapper = $xml->createElement("wrapper", $item->nodeValue); $element->parentNode->appendChild($cdataWrapper); } } } } // WA for segmentation fault starts here ... $xml->save("xml/$hostname.wrapper.xml"); $xml = new DOMDocument; $xml->formatOutput = true; $xml->load("xml/$hostname.wrapper.xml"); // WA for segmentation fault ends here ... $xsl = new DOMDocument; $xsl->load("xml/wrapper.xsl"); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); print(trim($proc->transformToXML($xml))); // --> Might cause a segmentation fault
  3. Hello, my following PHP code i.e. the last line causes a segmentation fault from time to time: $xml = new DOMDocument; $xml->formatOutput = true; $xml->load("xml/$hostname.log.xml"); $elements = $xml->getElementsByTagName("*"); foreach($elements as $element) { $type = $element->getAttribute('type'); $title = $element->getAttribute('title'); if($type == 'comment' or $title == 'Installed Packages') { foreach($element->childNodes as $item) { if($item->nodeType == 4) // XML_CDATA_SECTION_NODE { $cdataWrapper = $xml->createElement("wrapper", $item->nodeValue); $element->parentNode->appendChild($cdataWrapper); } } } } $xsl = new DOMDocument; $xsl->load("xml/wrapper.xsl"); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); print(trim($proc->transformToXML($xml))); // --> Might cause a segmentation fault Instead of print I also tried echo. Then, I thought it might be a timing issue and thus, I added a usleep but this could not solve my problem. I also restarted the apache server and cleaned up the memory and swap without success. I'm able to call the page up to five times w/o having any problem but afterwards the segmentation fault is written to the apache error log and the HTML code following after the print is not displayed anymore. I'm using Apache/2.2.22 (Unix) PHP/5.4.0 with libxml 2.7.8 and libxslt 1.1.26 as well on a Linux platform. Any help is highly appreciated! PS: The wrapper is used to additional encapsulate CDATA blocks to be able to address them separately within a wrapper tag. For more details about the wrapper see my other post "How to address CDATA blocks".
  4. Based on Martin's idea I could solve my problem: $xml = new DOMDocument; $xml->formatOutput = true; $xml->load("xml/$hostname.log.xml"); $elements = $xml->getElementsByTagName("*"); foreach($elements as $element) { foreach($element->childNodes as $item) { if( $item->nodeType == 4 ) // XML_CDATA_SECTION_NODE { $cdataWrapper = $xml->createElement("wrapper", $item->nodeValue); $element->parentNode->appendChild($cdataWrapper); // $item->parentNode->replaceChild($cdataWrapper, $item); } } } $xsl = new DOMDocument; $xsl->load("xml/wrapper.xsl"); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); print(trim($proc->transformToXML($xml))); Unfortunately, the replaceChild method did not work for me but I guess it's because I need the for-loop starting with the last cdata block as proposed by Martin. Anyway, this code adds XML wrapper tags for each cdata block separately which I can address via XSLT: <xsl:when test="wrapper"> <td><xsl:for-each select="wrapper"> <xsl:value-of select="." /><br /> </xsl:for-each></td> </xsl:when> Thanks to all who were supporting me!
  5. Thanks, Martin! I'll try to check this out but it can take a while since I'm a beginner in PHP, too ;-)
  6. I'm calling the XSLT processor using PHP. Maybe, I have some possibilities to manipulate cdata in within PHP call? Here comes the code snipet: $xml = new DOMDocument;$xml->load("xml/$hostname.log.xml");$xsl = new DOMDocument;$xsl->load("xml/results.xsl");$proc = new XSLTProcessor;$proc->importStyleSheet($xsl);print(trim($proc->transformToXML($xml))); Thanks so far!
  7. In case one cannot address cdata separately using XPATH neither with XSLT 1.0 nor with 2.0 maybe you have an idea to modify the cdata within a template. I already tried XSL function like substring-before and substring-after but this does not work for me. PS: Within Perl I would implement a pattern match for "string = string" but how to do this using XSL?
  8. So far I'm using version 1.0 but 2.0 could also be possible to be implemented.
  9. Hi everybody, I'm new to XSLT and face a problem with cdata which is most probably a simple question for you. I have following XML input (which is mandatory): <table title="Installed Packages" separator="=" caption="true" appendix="false"> <![CDATA[Variant Name = APS]]> <![CDATA[b04hlr02a_VD = Z04Y5V641200]]> ...</table> I'd like to address each cdata line separately but I don't know how. The corresponding XSLT part looks like that: <xsl:when test="table[@title='Installed Packages']"> <tr id="trResultOK"> <td style="text-align:center"><xsl:value-of select="id"/></td> <td style="text-align:center"><xsl:value-of select="result"/></td> <td style="text-align:center"><xsl:value-of select="priority"/></td> <td><xsl:value-of select="text[@type='description']"/></td> <td><xsl:value-of select="table"/></td> </tr></xsl:when> As you can see, for now I address the table element just as a whole but I'd like to have each cdata block separately i.e. every cdata should be one line in the HTML document ending with a newline. Or with other words the table data should have separate lines for each single cdata block. The HTML could look like following: <td> Variant Name = APS<br /> b04hlr02a_VD = Z04Y5V641200<br /> ...</td> I'd be very thankful for any help.
×
×
  • Create New...