Top > OOoBasic > Generic > XSLT

XSLT Edit

OpenOffice.org では XSL スタイルシートによる ODF ドキュメント変換が行えます。この機能は Java が必要です。

com.sun.star.documentconversion.XSLTFilter サービスを利用して XSLT が行えます。

JAXTHelper Edit

OOo Basic から XSLT を行います。変換終了前に OOo Basic の処理が終わらないようにリスナーを使用して終了を検知する必要があります。

'Dim oJAXHelper As Object
Dim bStarted As Boolean

Sub Main
  bStarted = True
  oSFA = CreateUnoService( _
    "com.sun.star.ucb.SimpleFileAccess" )
  
  oIn = oSFA.openFileRead("file:///C:/usr/content.xml")
  oOut = oSFA.openFileWrite("file:///C:/usr/out.txt")
  
  Dim aNamed(6) As New com.sun.star.beans.NamedValue
  aNamed(0).Name = "StylesheetURL"
  aNamed(0).Value = "file:///C:/usr/PukiWiki.xsl"
  aNamed(1).Name = "SourceURL"
  aNamed(1).Value = "file:///C:/usr/content.xml"
  aNamed(2).Name = "TargetURL"
  aNamed(2).Value = "file:///C:/usr/out.txt"
  aNamed(3).Name = "SourceBaseURL"
  aNamed(3).Value = "file:///C:/usr/"
  aNamed(4).Name = "TargetBaseURL"
  aNamed(4).Value = "file:///C:/usr/"
  aNamed(5).Name = "SystemType"
  aNamed(5).Value = ""
  aNamed(6).Name = "PublicType"
  aNamed(6).Value = ""
  
  oStreamListener = CreateUnoListener( "Stream_", _
    "com.sun.star.io.XStreamListener" )
  
  oJAXHelper = CreateUnoService( _
      "com.sun.star.comp.JAXTHelper" )
  oJAXHelper.initialize(aNamed)
  oJAXHelper.addListener(oStreamListener)
  oJAXHelper.setInputStream(oIn)
  oJAXHelper.setOutputStream(oOut)
  
  ' start translation
  oJAXHelper.start()
  
  ' needs to wait the end of translation
  While bStarted
    wait 100
  WEnd
  
  oJAXHelper.removeListener(oStreamListener)
  oIn.closeInput()
  oOut.closeOutput()
End Sub


Sub Stream_started
  'msgbox "started"
  bStarted = True
End Sub
Sub Stream_closed 
  'msgbox "closed"
  bStarted = False
End Sub
Sub Stream_terminated 
  'msgbox "terminated"
  bStarted = False
End Sub
Sub Stream_error( aException )
  bStarted = False
End Sub
Sub Stream_disposing( oEv )
  bStarted = False
End Sub

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes