%REM
*********************************************
Agent XSLT
Created May 21, 2015 by Mikhail Cholokov/CRUINTERNET
Description: Comments for Agent
%END REM
Option Public
Option Declare
Use "ErrorHandling"
Const xml=_
|<htmlx xmlns="http://www.w3.org/1999/xhtml"><RootElement1>
<Element2 Type="S2">123</Element2>
<Element3>
<E4>44444</E4>
<E5>5555</E5>
</Element3>
<Element6>66666</Element6>
</RootElement1></htmlx>|
'xmlns:xs="http://www.w3.org/2001/XMLSchema"
'exclude-result-prefixes="xs"
Const xsl=_
|<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xx="http://www.w3.org/1999/xhtml"
version="2.0">
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="xx:RootElement1">
<xsl:apply-templates select="xx:Element3"/>
</xsl:template>
<xsl:template match="xx:Element3">
<xsl:copy-of select="."/>
<!--<xsl:copy-of select="*"/>-->
</xsl:template>
</xsl:stylesheet>|
Sub Initialize
MsgBox Transform(xml,xsl)
End Sub
%REM
*--------------------------------------------
Function Transform
Description: Comments for Function
%END REM
function Transform(xml As String, xsl As String) As String
Dim routineName As String
routineName="Transform"
On Error GoTo ErrH
'your code here
Dim transformer As NotesXSLTransformer, ses As New NotesSession
Dim strmXML As NotesStream, strmXSL As NotesStream, res As NotesStream
Set strmXML=ses.Createstream():Set strmXSL=ses.Createstream():Set res=ses.CreateStream()
strmXML.writetext(xml):strmXSL.Writetext(xsl)
Set transformer=ses.CreateXSLTransformer(strmXML, strmXSL, res)
transformer.Inputvalidationoption=False
Call transformer.Process()
res.Position=0
Do
Transform=Transform & res.Readtext()
Loop Until res.isEOS
Quit:
Exit Function
ErrH:
Error Err, RaiseError
Resume Quit
End Function