0
我試圖使用JSON對XML功能JSON數據轉換爲XML的XSLT 3.0,但並不如預期JSON在XSLT XML轉換3.0
例如輸入JSON產生的XML:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}從XSLT3.0
生成的XML:
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<map key="glossary">
<string key="title">example glossary</string>
<map key="GlossDiv">
<string key="title">S</string>
<map key="GlossList">
<map key="GlossEntry">
<string key="ID">SGML</string>
<string key="SortAs">SGML</string>
<string key="GlossTerm">Standard Generalized Markup Language</string>
<string key="Acronym">SGML</string>
<string key="Abbrev">ISO 8879:1986</string>
<map key="GlossDef">
<string key="para">A meta-markup language, used to create markup languages such as DocBook.</string>
<array key="GlossSeeAlso">
<string>GML</string>
<string>XML</string>
</array>
</map>
<string key="GlossSee">markup</string>
</map>
</map>
</map>
預期的XML格式:
<glossary>
<title>example glossary</title>
<GlossDiv>
<title>S</title>
<GlossList>
<GlossEntry>
<ID>SGML</ID>
<SortAs>SGML</SortAs>
<GlossTerm>Standard Generalized Markup Language</GlossTerm>
<Acronym>SGML</Acronym>
<Abbrev>ISO 8879:1986</Abbrev>
<GlossDef>
<para>A meta-markup language, used to create markuplanguages such as DocBook.</para>
<GlossSeeAlso OtherTerm="GML">
<GlossSeeAlso OtherTerm="XML">
</GlossDef>
<GlossSee OtherTerm="markup">
</GlossEntry>
</GlossList>
</GlossDiv>
</glossary>
我的專業在這裏的問題是忽略這些關鍵屬性和打印屬性(鍵)值作爲元素名稱和實際文本作爲元素的文本。
你們能幫我實現這個嗎?
Thankyou Michael,這完全解決了我的問題。 – PhanidharSwarna
這怎麼可能導致xml可以用於進一步轉換例如我試圖應用下面的代碼後上述模板,但無法得到任何結果 \t \t的 \t \t \t的 \t \t的 \t \t \t XSL:元件> \t \t XS l:template> –
PhanidharSwarna
請提出一個新問題,不要提出補充問題作爲對答案的評論。 (並且不要將代碼放在評論中,它不可讀。) –