私はメッセージを変換し、古い名前空間を新しい名前空間に置き換える必要があるプロジェクトに取り組んでいます。私はそのコンポーネントが正しく動作している。スキーマ属性が変更されていません。私は別にそれを行うことができますが、私はスキーマの名前空間と要素の名前空間を変更することはできません。私はここで何が欠けていますか?ここでXMLメッセージの変換はスキーマを変更しません
はメッセージである:ここでは
<ns1:SupportNotificationMsg xsi:schemaLocation="http://namespace1.com:8081/Organization/SupportServices SupportServices.xsd"
xmlns:ns3="http://namespace3.com/Common"
xmlns:ns1="http://namespace1.com:8081/Organization/SupportServices"
xmlns:ns2="http://namespace2.com:8081/Organization/"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:j="http://www.it.ojp.gov/jxdm/3.0.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:SupportNotification>
<ns3:MessageHeader>
<ns3:MessageSender>
<ns3:OrganizationName>ORG</ns3:OrganizationName>
<ns3:ApplicationName>SEARCH</ns3:ApplicationName>
<ns3:ContactName>Support</ns3:ContactName>
<ns3:ContactPhoneNumber>111-222-3333</ns3:ContactPhoneNumber>
</ns3:MessageSender>
<ns3:MessageSentDateTime>2017-03-17T12:14:33</ns3:MessageSentDateTime>
</ns3:MessageHeader>
<ns2:SupportID>11243</ns2:SupportID>
<ns2:IdSetting idKey="123456">
<ns2:IdName ns2:code="APP1">ApplicationName</ns2:IdName>
<ns2:IdTypeText ns2:code="HLP">HelpDesk</ns2:IdTypeText>
<ns2:Setting settingKey="3091062">
<ns2:SupportDateTimes>2017-03-17T08:30:00-05:00</ns2:SupportDateTimes>
<ns2:SupportSettingStatus>Open</ns2:SupportSettingStatus>
</ns2:Setting>
</ns2:IdSetting>
</ns2:SupportNotification>
</ns1:SupportNotificationMsg >
変換です:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:NS1="http://namespace1.com:8081/Organization/SupportServices"
xmlns:NS2="http://namespace2.com:8081/Organization/"
xmlns:NS3="http://namespace3.com/Common"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="NS1:*">
<xsl:element name="{local-name()}"
namespace="http://newnamespace1.com/Organization/SupportServices">
<xsl:attribute name="xsi:schemaLocation">http://newnamespace1.com/Organization/SupportServices SupportServices.xsd</xsl:attribute>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="NS2:*">
<xsl:element name="{local-name()}"
namespace="http://newnamespace2.com/Organization/">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="NS3:*">
<xsl:element name="{local-name()}"
namespace="http://newnamespace3.com/Common">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
私は
<xsl:template match="/attribute::xsi:schemaLocation"/>
または
<xsl:template match="/@xsi:schemaLocation[. = 'http://namespace1.com:8081/Organization/SupportServices SupportServices.xsd']">
<xsl:attribute name="xsi:schemaLocation">http://newnamespace1.com/Organization/SupportServices SupportServices.xsd</xsl:attribute>
</xsl:template>
を追加しました
これは古いスキーマでも検証されますが、自分のベストプラクティスのために変更したいと思っています。
洞察力があれば幸いです。
が要求されるようにあなたの構造を変換するために、次のXSLTを使用することができます
デイブ
'/'属性を持っていることはありません(唯一の要素が属性を持っている)ので、私はあなたが '/ @のXSIと一致したいのかわからないと、選択した文書ノード:schemaLocation'の属性と一致するようにしようとするだろうドキュメントノード –