PDA

View Full Version : how to show the xml with xsl in a window



herry
17 Sep 2009, 7:59 PM
xml file SourceInfo.xml:


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="sourceInfo.xslt"?>
<TaskSourceInfo RunTimeInSecond="4294967295" Reserve="0" ReserveString="">
<VideoFileInfo>
<SourceElement Index="0" IfClosed="1" FinishFileSeriesNo="1" TrimIn="0" TrimOut="0" Duration="0" IsSingleFrame="0" IsNull="0" LoopTimes="1" StartTimeCode="4294967295" StreamMediaType="1" StreamMediaSubType="0" IsIncludeVideo="true" IsIncludeAudio="false">
<FileInfo SystemID="GlobalEMBCache" StorageID="EMBDisk1Storage1" IsFTPFileType="0" FilePath="Local\E:\Diary" FileName="Src-V_BD97029B-6B80-4AFF-9B9A-63C75E43BEA4.avi" FileSize="0" PathID="" PhysicalStatus="1" FileLength="0">
<FTPServerInfo Type="0" IP="100.0.0.2" Port="21" Username="guest" Password="dayang"/>
<DualPathInfo SystemID="" StorageID="" IsFTPFileType="0" FilePath="" FileName="" PathID="" PhysicalStatus="0"/>
</FileInfo>
<VideoMediaInfo Width="720" Height="576" StandardRate="25" StandardScale="1" ScanMode="0" ChromaFormat="512" VideoType="4" VideoSubType="0" DataRateInBitsPerSec="50000000" IsConstantRate="1" GOPSize="1" ReferencePeriod="1" IsY16_235="1"/>
<AudioMediaInfo AudioType="1" AudioSubType="0" Channels="1" BitsPerSample="16" SamplesPerSec="48000" AvgBitsPerSec="768000" BlockAlign="2"/>
<MD5 InputValue="" RightValue="" VerifyResult="0"/>
</SourceElement>
</VideoFileInfo>
<AudioFileInfo>
<Channel Index="0">
<SourceElement Index="0" IfClosed="1" FinishFileSeriesNo="1" TrimIn="0" TrimOut="481728" Duration="481728" IsSingleFrame="0" IsNull="0" LoopTimes="1" StartTimeCode="4294967295" StreamMediaType="4" StreamMediaSubType="0" IsIncludeVideo="false" IsIncludeAudio="true">
<FileInfo SystemID="GlobalEMBCache" StorageID="EMBDisk1Storage1" IsFTPFileType="0" FilePath="Local\E:\Diary" FileName="Src-A1_72B4EB45-CB91-491B-8FD8-E90C122973FE.wav" FileSize="0" PathID="" PhysicalStatus="1" FileLength="0">
<DualPathInfo SystemID="" StorageID="" IsFTPFileType="0" FilePath="" FileName="" PathID="" PhysicalStatus="0"/>
</FileInfo>
<VideoMediaInfo Width="720" Height="576" StandardRate="25" StandardScale="1" ScanMode="0" ChromaFormat="1024" VideoType="0" VideoSubType="0" DataRateInBitsPerSec="25000000" IsConstantRate="1" GOPSize="14" ReferencePeriod="2" IsY16_235="1"/>
<AudioMediaInfo AudioType="1" AudioSubType="0" Channels="1" BitsPerSample="24" SamplesPerSec="48000" AvgBitsPerSec="1152000" BlockAlign="3"/>
<MD5 InputValue="" RightValue="" VerifyResult="0"/>
</SourceElement>
</Channel>
<Channel Index="1">
<SourceElement Index="0" IfClosed="1" FinishFileSeriesNo="1" TrimIn="0" TrimOut="481728" Duration="481728" IsSingleFrame="0" IsNull="0" LoopTimes="1" StartTimeCode="4294967295" StreamMediaType="4" StreamMediaSubType="0" IsIncludeVideo="false" IsIncludeAudio="true">
<FileInfo SystemID="GlobalEMBCache" StorageID="EMBDisk1Storage1" IsFTPFileType="0" FilePath="Local\E:\Diary" FileName="Src-A2_2F97422E-B9FE-458A-9CAF-3C6D4A5B5921.wav" FileSize="0" PathID="" PhysicalStatus="1" FileLength="0">
<DualPathInfo SystemID="" StorageID="" IsFTPFileType="0" FilePath="" FileName="" PathID="" PhysicalStatus="0"/>
</FileInfo>
<VideoMediaInfo Width="720" Height="576" StandardRate="25" StandardScale="1" ScanMode="0" ChromaFormat="1024" VideoType="0" VideoSubType="0" DataRateInBitsPerSec="25000000" IsConstantRate="1" GOPSize="14" ReferencePeriod="2" IsY16_235="1"/>
<AudioMediaInfo AudioType="1" AudioSubType="0" Channels="1" BitsPerSample="24" SamplesPerSec="48000" AvgBitsPerSec="1152000" BlockAlign="3"/>
<MD5 InputValue="" RightValue="" VerifyResult="0"/>
</SourceElement>
</Channel>
</AudioFileInfo>
<DYCFileInfo/>
</TaskSourceInfo>


xls:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/TaskSourceInfo">
<html>
<head>
<style type="text/css"><![CDATA[
.div {
border: 1;
align: center;
bordercolordark: #6B78A9;
bordercolorlight: #6B78A9;
bgcolor: "#6B78A9";
width: "98%";
}

div span.span {
margin-left: 20px;
background-color: #FFFFFE
}

ul li {
list-style-image: url( 'images/eg_arrow.gif' )
}
]]></style>
</head>
<body>
<div>
<ul>
<div class="div">
<li>VideoFileInfo</li>
<xsl:copy>
<xsl:apply-templates select="./VideoFileInfo/node()"/>
</xsl:copy>
</div>
<div class="div">
<li>AudioFileInfo</li>
<ul>
<xsl:for-each select="//Channel">
<li>Channel_<xsl:value-of select="@Index"/>
</li>
<ul>
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</ul>
</xsl:for-each>
</ul>
</div>
</ul>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="//SourceElement">
<ul>
<li>SourceElement</li>
<div>
<span class="span">
<strong>Index:</strong>
<xsl:value-of select="@Index"/>
</span>
<span class="span">
<strong>IfClosed:</strong>
<xsl:value-of select="@IfClosed"/>
</span>
<span class="span">
<strong>FinishFileSeriesNo:</strong>
<xsl:value-of select="@FinishFileSeriesNo"/>
</span>
<span class="span">
<strong>TrimIn:</strong>
<xsl:value-of select="@TrimIn"/>
</span>
<span class="span">
<strong>TrimOut:</strong>
<xsl:value-of select="@TrimOut"/>
</span>
</div>
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</ul>
</xsl:template>
<xsl:template match="//FileInfo">
<ul>
<li>FileInfo</li>
<div>
<div>
<span class="span">
<strong>FileName:</strong>
<xsl:value-of select="@FileName"/>
</span>
</div>
<div>
<span class="span">
<strong>SystemID:</strong>
<xsl:value-of select="@SystemID"/>
</span>
<span class="span">
<strong>StorageID:</strong>
<xsl:value-of select="@StorageID"/>
</span>
<span class="span">
<strong>PathID:</strong>
<xsl:value-of select="@PathID"/>
</span>
</div>
<div>
<span class="span">
<strong>PhysicalStatus:</strong>
<xsl:value-of select="@PhysicalStatus"/>
</span>
<span class="span">
<strong>FileLength:</strong>
<xsl:value-of select="@FileLength"/>
</span>
</div>
</div>
<ul>
<li>FTPServerInfo</li>
<li>DualPathInfo</li>
</ul>
</ul>
</xsl:template>
</xsl:stylesheet>



while how can show the xml file after processed by the xslt in a Ext.Window?
something like :
new Ext.Window({
autoLoad :'SourceInfo.xml',
width:600,
height:500
}).show();
cannot show the xml file because the xml file havenot process by the xsl auto.
Can anyone help me ?

salamo
25 Sep 2010, 9:59 AM
Try to build a JSP or PHP page to apply the XSLT transformation on the server side. Then replace the 'SourceInfo.xml' reference to this new url.