HTMLファイルに変換を適用しようとしています。変換はdivとspanで正しく機能しますが、Pタグを挿入するとすぐに失敗します。
私が変換しているHTMLファイルは次のとおりです。
<!DOCTYPE html>
<html>
<head>
<title>STREAM Interactive - UAT</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<p>my para</p>
</body>
</html>
変換ファイルは非常に単純です。
<html xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<head>
<title xdt:Transform="Replace">TITLEHEADINGHERE</title>
</head>
</html>
変換を行うために使用されるプロジェクトファイルは次のとおりです。
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.Dll"/>
<PropertyGroup>
<SourceFile>web.config</SourceFile>
<TransformFile>web.debug.config</TransformFile>
<OutputFile>final.config</OutputFile>
</PropertyGroup>
<Target Name="GenerateConfigs">
<Message Text="Beginning Transformation." />
<Message Text="$(SourceFile)" />
<TransformXml Source="$(SourceFile)" Transform="$(TransformFile)" Destination="$(OutputFile)" />
<Message Text="Completed Transformation." />
</Target>
</Project>
使用されるコマンドは次のとおりです。
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe D:\SAM\SAMSite\bin\msbuild-transform-Template.xml /p:SourceFile="C:\temp\buildTest\BlueZone\2.3.10.5\PublishedClickOnce\index.html" /p:TransformFile="D:\SAM\SAMSite\bin\TransformTemplates\clickonce.index.transform.temp" /p:OutputFile="C:\temp\buildTest\BlueZone\2.3.10.5\PublishedClickOnce\index.html.temp"
私が得る出力/エラーは次のとおりです。
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.269]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 02/07/2012 10:54:33.
Project "D:\SAM\SAMSite\bin\msbuild- transform-Template.xml" on node 1 (default targets).
GenerateConfigs:
Beginning Transformation.
C:\temp\buildTest\BlueZone\2.3.10.5\PublishedClickOnce\index.html
Transforming Source File: C:\temp\buildTest\BlueZone\2.3.10.5\PublishedClickOnce\index.html
Transformation succeeded
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: The "TransformXml" task failed unexpectedly.
D:\SAM\SAMSite\bin\msbuild-transform- Template.xml(13,3): error MSB4018: System.UriFormatException: Invalid URI: The URI is empty.
D:\SAM\SAMSite\bin\msbuild-transform- Template.xml(13,3): error MSB4018: at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Web.Publishing.Tasks.TransformXml.Execute()
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
Done Building Project "D:\SAM\SAMSite\bin\msbuild-transform-Template.xml" (default targets) -- FAILED.
Build FAILED.
"D:\SAM\SAMSite\bin\msbuild-transform-Template.xml" (default target) (1) ->
(GenerateConfigs target) ->
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: The "TransformXml" task failed unexpectedly.
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: System.UriFormatException: Invalid URI: The URI is empty.
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Web.Publishing.Tasks.TransformXml.Execute()
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
D:\SAM\SAMSite\bin\msbuild-transform-Template.xml(13,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.09
HTMLは可能な限り最小限に抑えられており、以前はdivとspanが含まれていました。興味深いことに、Pタグにクラスを指定すると機能します。
なぜそうなるのか私にはわかりません。
編集
@Kierenの提案に従って、TransformXmlを直接使用して実行しようとしました。新しいエラーが発生します:
Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.Web.Publishing.Tasks.XmlAttributePreservationDict.ReadPreservationInfo(String elementStartTag)
at Microsoft.Web.Publishing.Tasks.XmlAttributePreservationProvider.GetDictAtPosition(Int32 lineNumber, Int32 linePosition)
at Microsoft.Web.Publishing.Tasks.XmlFileInfoDocument.XmlFileInfoElement..ctor(String prefix, String localName, String namespaceUri, XmlFileInfoDocument document)
at Microsoft.Web.Publishing.Tasks.XmlFileInfoDocument.CreateElement(String prefix, String localName, String namespaceURI)
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Web.Publishing.Tasks.XmlFileInfoDocument.LoadFromTextReader(TextReader textReader)
at Microsoft.Web.Publishing.Tasks.XmlFileInfoDocument.LoadFromFileName(String filename)
at Microsoft.Web.Publishing.Tasks.XmlFileInfoDocument.Load(String filename)
at QuickTests.TestTransformXml.OpenSourceFile(String sourceFile) in C:\Users\jon\Documents\Visual Studio 2010\Projects\QuickTests\QuickTests\TestTransformXmlTask.cs:line 140