将文本字段从xml / xslt提取到html或任何文本文件?

时间:2018-04-02 17:46:00

标签: xml xslt

我试着解决一个实际的问题,但它似乎并不那么复杂,但我真的很挣扎。这是从final cut pro 10导出的xml文件。它包含字幕 编辑!!(我得到了它的工作,它工作正常,但它输出文本在一个连续的行与破折号介于两者之间如何在一个新行上?)

这是第1行 这是第2行(所有中间居中)

这是第1行 这是第2行 - 全部用斜体

这是第1行 这是第2行的粗体

  • 这是双话1
  • 这是双重说法2所有左对齐

自定义标题行1 自定义第2行

中型发电机 第1行加上

中间发电机线2 加上输入的第2行

代码看起来像..................(只有前30行是相关的)

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" version="2.0" href="filename.xsl"?>
<!DOCTYPE fcpxml>

<fcpxml version="1.7">
    <resources>
        <format id="r1" name="FFVideoFormatDV720x576i50" frameDuration="200/5000s" fieldOrder="lower first" width="720" height="576" paspH="59" paspV="54" colorSpace="5-1-6 (Rec. 601 (PAL))"/>
        <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
        <effect id="r3" name="Custom" uid=".../Titles.localized/Build In:Out.localized/Custom.localized/Custom.moti"/>
        <effect id="r4" name="Middle" uid=".../Titles.localized/Lower Thirds.localized/Middle.localized/Middle.moti"/>
    </resources>
    <library location="file:///Users/leonore/Movies/FCP%20X%20test.fcpbundle/">
        <event name="Captions test" uid="2215EAC2-906E-4187-A312-C5EDCF309AC7">
            <project name="Untitled Project" uid="95CC4E58-3904-4445-9AC0-937615D6F9C5" modDate="2018-04-02 12:16:13 +0200">
                <sequence duration="266400/5000s" format="r1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
                    <spine>
                        <title name="This is line 1 - Basic Title" offset="0s" ref="r2" duration="50200/5000s" start="3600s">
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3000025419/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                            <text>
                                <text-style ref="ts1">This is line 1
And this is line 2 (all middle centered)</text-style>
                            </text>
                            <text-style-def id="ts1">
                                <text-style font="Helvetica" fontSize="63" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                        </title>
                        <title name="This is line 1 - Basic Title" offset="50200/5000s" ref="r2" duration="50200/5000s" start="3600s">
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3000025501/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                            <param name="Font" key="9999/999166631/999166633/5/999166635/83" value="93 1"/>
                            <text>
                                <text-style ref="ts2">This is line 1
This is line 2 - all in italics</text-style>
                            </text>
                            <text-style-def id="ts2">
                                <text-style font="Helvetica" fontSize="63" fontFace="Oblique" fontColor="1 0.999974 0.999991 1" italic="1" alignment="center"/>
                            </text-style-def>
                        </title>
                        <title name="This is line 1 - Basic Title" offset="100400/5000s" ref="r2" duration="50200/5000s" start="3600s">
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3000025618/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                            <text>
                                <text-style ref="ts3">This is line 1
This is line 2 all in bold</text-style>
                            </text>
                            <text-style-def id="ts3">
                                <text-style font="Helvetica" fontSize="63" fontColor="1 0.999974 0.999991 1" bold="1" alignment="center"/>
                            </text-style-def>
                        </title>
                        <title name="- This is double speak 1 - Basic Title" offset="150600/5000s" ref="r2" duration="50200/5000s" start="3600s">
                            <param name="Position" key="9999/999166631/999166633/1/100/101" value="-520.415 -6.668e-12"/>
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3000025751/401" value="0 (Left)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="0 (Left)"/>
                            <text>
                                <text-style ref="ts4">- This is double speak 1
- This is double speak 2 all left-aligned</text-style>
                            </text>
                            <text-style-def id="ts4">
                                <text-style font="Helvetica" fontSize="63" fontFace="Regular" fontColor="1 0.999974 0.999991 1"/>
                            </text-style-def>
                        </title>
                        <title name="Custom title line 1 - Custom" offset="200800/5000s" ref="r3" duration="25200/5000s" start="3600s">
                            <param name="Alignment" key="9999/10199/10201/2/354/1002961760/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/10199/10201/2/354/3001205098/401" value="1 (Center)"/>
                            <param name="Out Sequencing" key="9999/10199/10201/4/10233/201/202" value="0 (To)"/>
                            <text>
                                <text-style ref="ts5">Custom title line 1
Custom line 2</text-style>
                            </text>
                            <text-style-def id="ts5">
                                <text-style font="Helvetica" fontSize="72" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                        </title>
                        <title name="Middle generator - Middle" offset="226000/5000s" ref="r4" duration="20200/5000s" start="3600s">
                            <param name="Position" key="9999/10393/10394/1/100/101" value="2.39185 44.6384"/>
                            <param name="Inside Path" key="9999/10393/10394/2/329/332" value="0"/>
                            <param name="Shape Source" key="9999/10393/10394/2/329/339" value="0"/>
                            <param name="Phase" key="9999/10393/10394/2/329/346" value="0"/>
                            <param name="Attach To Shape" key="9999/10393/10394/2/329/348" value="1"/>
                            <param name="Damping" key="9999/10393/10394/2/329/349" value="0"/>
                            <param name="Align To Text" key="9999/10393/10394/2/329/353" value="0"/>
                            <param name="Editable in FCP" key="9999/10393/10394/2/350" value="1"/>
                            <param name="Flatten" key="9999/10393/10394/2/351" value="0"/>
                            <param name="Alignment" key="9999/10393/10394/2/354/1156459982/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/10393/10394/2/354/3001205313/401" value="1 (Center)"/>
                            <param name="Opacity" key="9999/10393/10394/2/366" value="1"/>
                            <param name="Position" key="9999/10393/10410/1/100/101" value="0.0657212 -86.9112"/>
                            <param name="Shape Source" key="9999/10393/10410/2/329/339" value="0"/>
                            <param name="Editable in FCP" key="9999/10393/10410/2/350" value="1"/>
                            <param name="Alignment" key="9999/10393/10410/2/354/1156460000/401" value="1 (Center)"/>
                            <text>
                                <text-style ref="ts6">Middle generator
Line 1 plus enter</text-style>
                            </text>
                            <text/>
                            <text-style-def id="ts6">
                                <text-style font="Gill Sans" fontSize="94" fontFace="Regular" fontColor="1 0.999974 0.999991 1" strokeColor="0 0 0 1" strokeWidth="4" shadowColor="0 0 0 0.75" shadowOffset="5 281.05" shadowBlurRadius="3.08901" alignment="center"/>
                            </text-style-def>
                        </title>
                        <title name="Middle" offset="246200/5000s" ref="r4" duration="20200/5000s" start="3600s">
                            <param name="Position" key="9999/10393/10394/1/100/101" value="2.39185 -15.8748"/>
                            <param name="Inside Path" key="9999/10393/10394/2/329/332" value="0"/>
                            <param name="Shape Source" key="9999/10393/10394/2/329/339" value="0"/>
                            <param name="Phase" key="9999/10393/10394/2/329/346" value="0"/>
                            <param name="Attach To Shape" key="9999/10393/10394/2/329/348" value="1"/>
                            <param name="Damping" key="9999/10393/10394/2/329/349" value="0"/>
                            <param name="Align To Text" key="9999/10393/10394/2/329/353" value="0"/>
                            <param name="Editable in FCP" key="9999/10393/10394/2/350" value="1"/>
                            <param name="Flatten" key="9999/10393/10394/2/351" value="0"/>
                            <param name="Alignment" key="9999/10393/10394/2/354/1156459982/401" value="1 (Center)"/>
                            <param name="Opacity" key="9999/10393/10394/2/366" value="1"/>
                            <param name="Position" key="9999/10393/10410/1/100/101" value="31.2122 1.02423"/>
                            <param name="Shape Source" key="9999/10393/10410/2/329/339" value="0"/>
                            <param name="Editable in FCP" key="9999/10393/10410/2/350" value="1"/>
                            <param name="Alignment" key="9999/10393/10410/2/354/1156460000/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/10393/10410/2/354/3001205753/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/10393/10410/2/354/3001205946/401" value="1 (Center)"/>
                            <text/>
                            <text>
                                <text-style ref="ts7">Middle generator line 1
plus entered line 2
</text-style>
                            </text>
                            <text-style-def id="ts7">
                                <text-style font="Gill Sans" fontSize="56" fontColor="1 0.999974 0.999991 1" bold="1" strokeColor="0 0 0 1" strokeWidth="4" shadowColor="0 0 0 0.6728" shadowOffset="3 315" alignment="center"/>
                            </text-style-def>
                        </title>
                    </spine>
                </sequence>
            </project>
        </event>
        <smart-collection name="Projects" match="all">
            <match-clip rule="is" type="project"/>
        </smart-collection>
        <smart-collection name="All Video" match="any">
            <match-media rule="is" type="videoOnly"/>
            <match-media rule="is" type="videoWithAudio"/>
        </smart-collection>
        <smart-collection name="Audio Only" match="all">
            <match-media rule="is" type="audioOnly"/>
        </smart-collection>
        <smart-collection name="Stills" match="all">
            <match-media rule="is" type="stills"/>
        </smart-collection>
        <smart-collection name="Favorites" match="all">
            <match-ratings value="favorites"/>
        </smart-collection>
    </library>
</fcpxml>

现在在这个尺寸下很容易将其复制出来,但显然程序会更酷,这就是我尝试但我无法让它工作。

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

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

<xsl:template match="/fcpxml">
	<html>
		<head>
		</head>
		<body>
			<xsl:for-each select="library/event/project/sequence/spine/title/text">
				<h1>
					<xsl:value-of select="text-style" />
				</h1>
			</xsl:for-each>
		</body>
	</html>



</xsl:template>

</xsl:stylesheet>

此时它甚至引用xsl文件它只是吐出代码,当我在IE中打开xml文件时,任何指针都会很棒谢谢!! (这一点的全部意义是将文本文件中的字幕拼写为拼写检查)

0 个答案:

没有答案