BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
PHP XSLT Function xslt_process
PHP XSLT Function xslt_getopt
PHP XSLT Function xslt_free
PHP XSLT Function xslt_error
PHP XSLT Function xslt_create
PHP SimpleXML Function New_Doc
PHP SimpleXML Function Save
PHP SimpleXML Function load_string
PHP SimpleXML Function Load_File
PHP SimpleXML Function LoadXML
PHP SimpleXML Function Load
PHP SimpleXML Function Open_File
PHP SimpleXML Function xml_parser_create
PHP SimpleXML Create an XML Document
PHP XML RPC Function Server Call method
PHP XML RPC Parse Method Descriptions
PHP XML RPC Function ServerCreate
PHP XML RPC Function GetType
PHP XML RPC Function EncodeRequest
PHP XML RPC Function Encode
 
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :244

 

PHP XSLT Function xslt_setopt

PHP Version: PHP 4 >= 4.0.3

Description

This function is used to set option on xslt processor. There are different options available for setting on xslt processor.

Available options:

  • XSLT_SABOPT_PARSE_PUBLIC_ENTITIES - Tell the processor to parse public entities. By default this has been turned off.
  • XSLT_SABOPT_DISABLE_ADDING_META - Do not add the Meta tag "Content-Type" for HTML output. The default is set during the compilation of the processor.
  • XSLT_SABOPT_DISABLE_STRIPPING - Suppress the whitespace stripping (on data files only).
  • XSLT_SABOPT_IGNORE_DOC_NOT_FOUND - Consider unresolved documents (the document () function) non-lethal.

Usage:

Int xslt_setopt ( processor xh, option)

This function sets option on the xslt processor. If the output of your xslt processing is an html file then by default processor will add META tag. If you want to remove this, you can use XSLT_SABOPT_DISABLE_ADDING_META.

Content of employee.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<employee>

            <employeename>test</employeename>

            <employeeaddress>test123</employeeaddress>

            <SSN>12343456</SSN>

            <company>XYZ Corporation</company>

</employee>

Content of xsl file:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>

<head><title>XSLT in PHP</title></head>

<body>

     <xsl:for-each select="//employee">

          <BR><B>Employee Name:<xsl:value-of select="employeename"/></B></BR>

          <BR><B>Employee Address:<xsl:value-of select="employeeaddress"/></B></BR>

          <BR><B>SSN:<xsl:value-of select="SSN"/></B></BR>

          <BR><B>Company:<xsl:value-of select="company"/></B></BR>

     </xsl:for-each>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

PHP Code:

In the below example, I have used XSLT_SABOPT_DISABLE_ADDING_META to disable of displaying meta tag in the output html.

<?php

$processor = xslt_create();

xslt_setopt($processor,XSLT_SABOPT_DISABLE_ADDING_META);

$transformed = xslt_process($processor, 'employee.xml', 'employee.xsl');

if (!$transformed) {

    die(sprintf("Error during XSLT transformation [%d]: %s",

                xslt_errno($processor), ", Error description:".xslt_error($processor)));

}

echo $transformed;

xslt_free($processor);

?>

Output

Employee Name:test

Employee Address:test123

SSN:12343456

Company:XYZ Corporation

Source of html page does not contain META tag.

<html>

  <head>

    <title>xslt_error</title>

  </head>

  <body>

  <html><head><title>XSLT in PHP</title></head><body><BR><B>Employee Name:test</B></BR><BR><B>Employee Address:test123</B></BR><BR><B>SSN:12343456</B></BR><BR><B>Company:XYZ Corporation</B></BR></body></html>

  </body>

</html>


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

An immediate job opportunity as a B
Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C

View all Jobs (Add yours)
View all CV (Add yours)



answering service
conference call service
swimming pool contractor
conference calls
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP