Строка XML в XML от XSLT - PullRequest
       0

Строка XML в XML от XSLT

0 голосов
/ 05 февраля 2019

Я хочу преобразовать данные XMLString в XML через xslt.Ниже приведен вход, т.е. XMLString: -

Вход: -

<Inputs><field name="Call_ID">MZ_CMI_AG_04082017_117</field><field name="PeopleRecordID">PPL00000000001</field><field name="CTN">1</field><field name="ContactName">IMIS_LoadTest1</field><field name="Notes" Local_Lang="Spanish" Destination_Local="Detailed_Description_Local" Destination_Eng="Detailed_Description_English">Mr. and Mrs. Dursley, of num.
  At half past eight, Mr. Parsley picked up his briefcase, pecked Mrs. Dursley on the cheek, and tried to kiss Dudley good-bye but missed, because Dudley was now having a tantrum and throwing his cereal at the walls. "Little tyke," chortled Mr. Parsley as he left the house. He got into his car and backed out of number four's drive. 
 he sign; cats couldn't read ted Mr. Parsley as he left the house. He got into his car and backed out of number four's drive. 
   to get that day.</field><field name="Summary" Local_Lang="Spanish" Destination_Local="Description_Local" Destination_Eng="Description_English">This is dummy data dummy data for test</field></Inputs>

Можете ли вы помочь мне с этим

1 Ответ

0 голосов
/ 05 февраля 2019

В соответствии с данными, которые вы дали, давайте поместим их в корневой элемент (<Root></Root>)

Например,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
    &lt;Inputs&gt;&lt;field
    name="Call_ID"&gt;MZ_CMI_AG_04082017_117&lt;/field&gt;&lt;field
    name="PeopleRecordID"&gt;PPL00000000001&lt;/field&gt;&lt;field
    name="CTN"&gt;1&lt;/field&gt;&lt;field
    name="ContactName"&gt;IMIS_LoadTest1&lt;/field&gt;&lt;field
    name="Notes" Local_Lang="Spanish"
    Destination_Local="Detailed_Description_Local"
    Destination_Eng="Detailed_Description_English"&gt;Mr. and Mrs. Dursley,
    of num.&#xD;
    At half past eight, Mr. Parsley picked up his briefcase, pecked Mrs.
    Dursley on the cheek, and tried to kiss Dudley good-bye but missed,
    because Dudley was now having a tantrum and throwing his cereal at the
    walls. "Little tyke," chortled Mr. Parsley as he left the house. He got
    into his car and backed out of number four's drive. &#xD;
    he sign; cats couldn't read ted Mr. Parsley as he left the house. He got
    into his car and backed out of number four's drive. &#xD;
    to get that day.&lt;/field&gt;&lt;field name="Summary"
    Local_Lang="Spanish" Destination_Local="Description_Local"
    Destination_Eng="Description_English"&gt;This is dummy data dummy data
    for test&lt;/field&gt;&lt;/Inputs&gt; 
</Root>

Если выше, то верноИсходя из вашего входного файла, вы можете преобразовать его в XML, используя xslt, как показано ниже:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output omit-xml-declaration="yes" />

<xsl:template match="/Root">
    <xsl:value-of select="normalize-space(.)" disable-output-escaping="yes" />
</xsl:template>
</xsl:stylesheet>

Найти преобразование здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...