0
XSLTを初めて使用していて、csproj-FileのReferencesからすべての "Private"タグを削除し、Private = "False"代わりにすべての "HintPath"のタグを使用します。XPATH式の一致= "TAGNAME"は一致しますが、 "PARENT/TAGNAME"は一致しません
XSLTを
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:DUMMY="http://schemas.microsoft.com/developer/msbuild/2003"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- use DUMMY namespace as default, would otherwise write missing ns explicitly -->
<xsl:output encoding="UTF-8" indent="yes"/> <!-- encoding as required for output file, indent=yes: would write all text in one line otherwise -->
<xsl:strip-space elements="*"/> <!-- delete all white spaces -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Private"/> <!-- obsolete line: without the namespace workaround: no match -->
<xsl:template match="DUMMY:Private"/> <!-- working line: only deletes tags itself, not indention -->
<xsl:template match="DUMMY:Reference/Private"/> <!-- obsolete line: Does not match! -->
<xsl:template match="DUMMY:Reference//Private"/> <!-- obsolete line: Does also not match! -->
<xsl:template match="DUMMY:HintPath">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
<xsl:element name="Private">
<xsl:text>False</xsl:text>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
サンプル入力ファイル:述べたように
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- The original document has an anonymous default namespace -->
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<ItemGroup>
<Reference Include="Configuration">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SolutionDir)..\..\public\Bin\$(Configuration)\Configuration.dll</HintPath>
</Reference>
<Reference Include="Core">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SolutionDir)..\..\public\Bin\$(Configuration)\Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Data">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SolutionDir)..\..\public\Bin\$(Configuration)\Data.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
</Project>
:私は完全に私がやっているものを理解せず、そのための作業溶液を書いた私の作品が、それはかなりでしたこれまでのところ見つけ出すのが難しい。 XSLTを使用してそのタスクを達成するより良い方法はありますか?
「参照」よりも「プライベート」タグがドキュメント内の他の場所に表示されると、付随的な損害が発生する可能性があります。しかし、親タグを含めて指定する方法が見つかりませんでした。何かヒント?
2番目の質問:ネームスペースを処理する簡単な方法はありますか?
ご提案は大歓迎です。