2012-02-14 12 views
1

私は2つの異なるxsltプロセッサを使用しています。 これらのうちの1つは、ターゲット内で空ではない要素を作成します(この要素はソース内で空でも)。マップするxslの書き方<xsl:text></xsl:text>

ポイントに到達するには、どのように私のxsl経由で のプロセッサにターゲットを作成する必要があることを伝えることができますか? (言い換えれば、その要素へのマッピング方法)。私は "AltovaのMapForceの" マッピングツールを使用していますが、私は、ノード間をマッピングしてい - 私の問題をclearifyするには:

EDITED。 結果のxml(altova xsltプロセッサを使用)にはノードが空ではありません。 結果のxml(ビジュアルxsltプロセッサを使用し、Altova Mapforceから生成されたxslを使用)は、空ではないノードを使用しています。 ノードはソース上で空です。

私の目標は、ソースノード(Altova MapForceマッピングツールを使用して)をカスタムの書かれたXSLTに接続し、それをターゲットに接続することです。ここ

私のコードである: in.xml - マップを実行するためのインスタンスの入力(空のIDタグに注意してください。)

<ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.Schema1"> 
    <id root="root_0" extension="extension_1" /> 
</ns0:Root> 

Schema1.xsd - ソースとターゲット・スキーマ

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://BizTalk_Server_Project1.Schema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Server_Project1.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="Root"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="id"> 
      <xs:complexType> 
      <xs:attribute name="root" type="xs:string" /> 
      <xs:attribute name="extension" type="xs:string" /> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

New.mfd - Altovaのマッピングファイル

<?xml version="1.0" encoding="UTF-8"?> 
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="19"> 
    <component name="defaultmap1" blackbox="0" uid="1" editable="1"> 
     <properties SelectedLanguage="xslt"/> 
     <structure> 
      <children> 
       <component name="document" library="xml" uid="4" kind="14"> 
        <properties/> 
        <view rbx="150" rby="200"/> 
        <data> 
         <root> 
          <header> 
           <namespaces> 
            <namespace/> 
            <namespace uid="http://BizTalk_Server_Project1.Schema1"/> 
            <namespace uid="http://www.altova.com/mapforce"/> 
           </namespaces> 
          </header> 
          <entry name="FileInstance" ns="2" expanded="1"> 
           <entry name="document" ns="2" expanded="1" casttotargettypemode="cast-in-subtree"> 
            <entry name="Root" ns="1" expanded="1"> 
             <entry name="id" expanded="1"> 
              <entry name="extension" type="attribute" outkey="4"/> 
             </entry> 
            </entry> 
           </entry> 
          </entry> 
         </root> 
         <document schema="Schema1.xsd" outputinstance="Schema1.xml" instanceroot="{http://BizTalk_Server_Project1.Schema1}Root"/> 
         <wsdl/> 
        </data> 
       </component> 
       <component name="document" library="xml" uid="5" kind="14"> 
        <properties XSLTDefaultOutput="1"/> 
        <view ltx="593" rbx="743" rby="200"/> 
        <data> 
         <root> 
          <header> 
           <namespaces> 
            <namespace/> 
            <namespace uid="http://BizTalk_Server_Project1.Schema1"/> 
            <namespace uid="http://www.altova.com/mapforce"/> 
           </namespaces> 
          </header> 
          <entry name="FileInstance" ns="2" expanded="1"> 
           <entry name="document" ns="2" expanded="1" casttotargettypemode="cast-in-subtree"> 
            <entry name="Root" ns="1" expanded="1"> 
             <entry name="id" expanded="1"> 
              <entry name="extension" type="attribute" inpkey="5"/> 
             </entry> 
            </entry> 
           </entry> 
          </entry> 
         </root> 
         <document schema="Schema1.xsd" outputinstance="Schema1.xml" instanceroot="{http://BizTalk_Server_Project1.Schema1}Root"/> 
         <wsdl/> 
        </data> 
       </component> 
      </children> 
      <graph directed="1"> 
       <edges/> 
       <vertices> 
        <vertex vertexkey="4"> 
         <edges> 
          <edge vertexkey="5" edgekey="6"/> 
         </edges> 
        </vertex> 
       </vertices> 
      </graph> 
     </structure> 
    </component> 
</mapping> 

Xsl.xsl - XSLは、Altovaのによって生成されましたマッパー

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://BizTalk_Server_Project1.Schema1" xmlns:agt="http://www.altova.com/Mapforce/agt" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="ns0 agt xs"> 
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/> 
    <xsl:template name="agt:var2_MapToSchema1_function"> 
     <xsl:param name="par0"/> 
     <xsl:attribute name="extension"> 
      <xsl:value-of select="string($par0/@extension)"/> 
     </xsl:attribute> 
    </xsl:template> 
    <xsl:template match="/"> 
     <Root xmlns="http://BizTalk_Server_Project1.Schema1"> 
      <xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">http://BizTalk_Server_Project1.Schema1 C:/Users/OhadAv/Desktop/ForAltova/Schema1.xsd</xsl:attribute> 
      <id xmlns=""> 
       <xsl:for-each select="ns0:Root/id"> 
        <xsl:variable name="var1_extension"> 
         <xsl:if test="@extension"> 
          <xsl:value-of select="'1'"/> 
         </xsl:if> 
        </xsl:variable> 
        <xsl:if test="string(boolean(string($var1_extension))) != 'false'"> 
         <xsl:call-template name="agt:var2_MapToSchema1_function"> 
          <xsl:with-param name="par0" select="."/> 
         </xsl:call-template> 
        </xsl:if> 
       </xsl:for-each> 
      </id> 
     </Root> 
    </xsl:template> 
</xsl:stylesheet> 

GeneratedByBizTalkMapperAfterXSLTmap.xml - (xmlファイルを編集する際に生成された非空のIDタグを注意してくださいマップの「Xsl.xsl」を使用した後のBizTalkマッパーの出力例:

<?xml version="1.0" encoding="utf-8"?> 
<Root xsi:schemaLocation="http://BizTalk_Server_Project1.Schema1 C:/Users/OhadAv/Desktop/ForAltova/Schema1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://BizTalk_Server_Project1.Schema1"> 
    <id extension="extension_1" xmlns=""> 
    </id> 
</Root> 
+1

:なしソースXML 、XSLTコードはありません(できるだけシンプルでシンプルなものにしてください)、望みの結果も実際の結果もありません...この推測を編集して実際の質問にしてください。 –

+1

@DimitreNovatchev、私はあなたに同意します.. –

+0

こんにちは。あなたの親切な助けをありがとう。 私はあなたの要求に私の質問を拡張しました。 – ohadinho

答えて

2

あなたの入力XML要素にスペースがある可能性があります。strip-spaceの使用は、あなたの仕事が完了する必要があります!

これは、リッピングオフノード間のスペース:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:strip-space elements="YourElement" /> 
<!--Your code here--> 

入力XML:

<a> 
    <b> </b> 
<a> 

出力XML:

<a> 
    <b/> 
</a> 

これは、ノード間のスペースを保持する:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:preserve-space elements="YourElement" /> 
<!--Your code here--> 

ソースXML

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:preserve-space elements="*" /> 

、あなたはすべての要素に対して同じルールを適用する場合:

<a> 
    <b> </b> 
</a> 

出力XML:

<a> 
    <b> </b> 
<a> 
+0

ヘッダーの宣言はこれとは関係ありません。 –

+0

あなたのソリューションはbiztalkマッププロセッサでは動作しません。 –

+0

@ハーム、対応するサンプルXMLと希望の出力を提供してください、私は質問者の文章に基づいてこの答えを出しました。あなたのケースで何が取引であるか分かりません。 –

1

次の変換は、2つの方法を示しています空の要素を作成する

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/> 
<xsl:strip-space elements="*"/> 

<xsl:template match="/"> 
    <t> 
     <a> 
     <b/> 
     </a> 
     <a> 
     <xsl:element name="b"/> 
     </a> 
    </t> 
</xsl:template> 
</xsl:stylesheet> 

7つの異なるXSLT(MSXML3。 MSXML4、MSXML6、.NET XslCompiledTransformでは、.NETのXslTransformは、サクソン6.5.4およびAltovaXML(XML-SPY)プロセッサは、2つの別々の<b/>要素を含まれています

<t> 
    <a> 
     <b/> 
    </a> 
    <a> 
     <b/> 
    </a> 
</t> 
あなたの "宿題" を行っていない
関連する問題