Модуль:Test/ED/doc

Материал из свободной русской энциклопедии «Традиция»
Перейти к навигации Перейти к поиску

Это страница документации Модуль:Test/ED.

Call Result
mw.ext.externaldata.getFileData
JSON with JSONPath
mw.ext.externaldata.getFileData {
    "use jsonpath"
  , file = "test"
  , data = "name=$.name,version=$.version"
  , format = "JSON"
}
"(error)"

"table#1 {\

 [\"72b1f104fce1a950942952f65d7bb877\"] = \"Файл test не определён.\",\

}"

Absent file
mw.ext.externaldata.getFileData {
    "use jsonpath"
  , file = "test1"
  , data = "name=$.name,version=$.version"
  , format = "JSON"
}
"(error)"

"table#1 {\

 [\"4e95f2542a622997f2ccde3730c16372\"] = \"Файл test1 не определён.\",\

}"

mw.ext.externaldata.getSoapData
Wrong URL
mw.ext.externaldata.getSoapData {
    "use xpath"
  , format = "XML"
  , request = "GetCurrentExchangeRates"
  , url = "http://www.falsemnb.hu/arfolyamok.asmx?wsdl"
  , data = table#1 {
  ["date"] = "/MNBCurrentExchangeRates/Day/@date",
  ["from"] = "/MNBCurrentExchangeRates/Day/Rate/@curr",
  ["from_nominal"] = "/MNBCurrentExchangeRates/Day/Rate/@unit",
  ["rate"] = "/MNBCurrentExchangeRates/Day/Rate",
}
  , response = "GetCurrentExchangeRatesResult"
}
"(error)"

"table#1 {\

 [\"2f27468eb8cedd5c5a75a6ad4d73ba3d\"] = \"При создании клиента SOAP выброшено исключение SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.falsemnb.hu/arfolyamok.asmx?wsdl' : failed to load external entity \\\"http://www.falsemnb.hu/arfolyamok.asmx?wsdl\\\"\\\

.\",\

 [\"93a612eea0e754bfc93d61eaaa05d641\"] = \"Не удалось получить URL http://www.falsemnb.hu/arfolyamok.asmx?wsdl после 3 попыток.\",\

}"

XML with xpath
mw.ext.externaldata.getSoapData {
    "use xpath"
  , format = "XML"
  , request = "GetCurrentExchangeRates"
  , url = "http://www.mnb.hu/arfolyamok.asmx?wsdl"
  , data = table#1 {
  ["date"] = "/MNBCurrentExchangeRates/Day/@date",
  ["from"] = "/MNBCurrentExchangeRates/Day/Rate/@curr",
  ["from_nominal"] = "/MNBCurrentExchangeRates/Day/Rate/@unit",
  ["rate"] = "/MNBCurrentExchangeRates/Day/Rate",
}
  , response = "GetCurrentExchangeRatesResult"
}
table#1 {
 table#2 {
   ["date"] = "2024-12-13",
   ["from"] = "AUD",
   ["from_nominal"] = "1",
   ["rate"] = "248,75",
 },
 table#3 {
   ["from"] = "BGN",
   ["from_nominal"] = "1",
   ["rate"] = "209,49",
 },
 table#4 {
   ["from"] = "BRL",
   ["from_nominal"] = "1",
   ["rate"] = "65,14",
 },
 table#5 {
   ["from"] = "CAD",
   ["from_nominal"] = "1",
   ["rate"] = "274,67",
 },
 table#6 {
   ["from"] = "CHF",
   ["from_nominal"] = "1",
   ["rate"] = "436,77",
 },
 table#7 {
   ["from"] = "CNY",
   ["from_nominal"] = "1",
   ["rate"] = "53,68",
 },
 table#8 {
   ["from"] = "CZK",
   ["from_nominal"] = "1",
   ["rate"] = "16,35",
 },
 table#9 {
   ["from"] = "DKK",
   ["from_nominal"] = "1",
   ["rate"] = "54,93",
 },
 table#10 {
   ["from"] = "EUR",
   ["from_nominal"] = "1",
   ["rate"] = "409,72",
 },
 table#11 {
   ["from"] = "GBP",
   ["from_nominal"] = "1",
   ["rate"] = "493,87",
 },
 table#12 {
   ["from"] = "HKD",
   ["from_nominal"] = "1",
   ["rate"] = "50,25",
 },
 table#13 {
   ["from"] = "IDR",
   ["from_nominal"] = "100",
   ["rate"] = "2,44",
 },
 table#14 {
   ["from"] = "ILS",
   ["from_nominal"] = "1",
   ["rate"] = "108,35",
 },
 table#15 {
   ["from"] = "INR",
   ["from_nominal"] = "1",
   ["rate"] = "4,61",
 },
 table#16 {
   ["from"] = "ISK",
   ["from_nominal"] = "1",
   ["rate"] = "2,80",
 },
 table#17 {
   ["from"] = "JPY",
   ["from_nominal"] = "100",
   ["rate"] = "254,65",
 },
 table#18 {
   ["from"] = "KRW",
   ["from_nominal"] = "100",
   ["rate"] = "27,23",
 },
 table#19 {
   ["from"] = "MXN",
   ["from_nominal"] = "1",
   ["rate"] = "19,30",
 },
 table#20 {
   ["from"] = "MYR",
   ["from_nominal"] = "1",
   ["rate"] = "87,80",
 },
 table#21 {
   ["from"] = "NOK",
   ["from_nominal"] = "1",
   ["rate"] = "35,12",
 },
 table#22 {
   ["from"] = "NZD",
   ["from_nominal"] = "1",
   ["rate"] = "225,19",
 },
 table#23 {
   ["from"] = "PHP",
   ["from_nominal"] = "1",
   ["rate"] = "6,66",
 },
 table#24 {
   ["from"] = "PLN",
   ["from_nominal"] = "1",
   ["rate"] = "95,90",
 },
 table#25 {
   ["from"] = "RON",
   ["from_nominal"] = "1",
   ["rate"] = "82,39",
 },
 table#26 {
   ["from"] = "RSD",
   ["from_nominal"] = "1",
   ["rate"] = "3,50",
 },
 table#27 {
   ["from"] = "RUB",
   ["from_nominal"] = "1",
   ["rate"] = "3,76",
 },
 table#28 {
   ["from"] = "SEK",
   ["from_nominal"] = "1",
   ["rate"] = "35,54",
 },
 table#29 {
   ["from"] = "SGD",
   ["from_nominal"] = "1",
   ["rate"] = "289,70",
 },
 table#30 {
   ["from"] = "THB",
   ["from_nominal"] = "1",
   ["rate"] = "11,45",
 },
 table#31 {
   ["from"] = "TRY",
   ["from_nominal"] = "1",
   ["rate"] = "11,18",
 },
 table#32 {
   ["from"] = "UAH",
   ["from_nominal"] = "1",
   ["rate"] = "9,40",
 },
 table#33 {
   ["from"] = "USD",
   ["from_nominal"] = "1",
   ["rate"] = "390,69",
 },
 table#34 {
   ["from"] = "ZAR",
   ["from_nominal"] = "1",
   ["rate"] = "21,80",
 },
 ["date"] = "2024-12-13",

}
"(no error)"

Broken WSDL
mw.ext.externaldata.getSoapData {
    "use xpath"
  , format = "XML"
  , request = "GetCurrentExchangeRates"
  , url = "http://www.mnb.de/arfolyamok.asmx?wsdl"
  , data = table#1 {
  ["date"] = "/MNBCurrentExchangeRates/Day/@date",
  ["from"] = "/MNBCurrentExchangeRates/Day/Rate/@curr",
  ["from_nominal"] = "/MNBCurrentExchangeRates/Day/Rate/@unit",
  ["rate"] = "/MNBCurrentExchangeRates/Day/Rate",
}
  , response = "GetCurrentExchangeRatesResult"
}
"(error)"

"table#1 {\

 [\"d134c8b58a803787a449a42c310f189b\"] = \"Не удалось получить URL http://www.mnb.de/arfolyamok.asmx?wsdl после 3 попыток.\",\

}"

mw.ext.externaldata.getDbData
mySQL
mw.ext.externaldata.getDbData {
    limit = 10
  , from = "family"
  , db = "rfam"
  , data = table#1 {
  ["name"] = "author",
  ["number"] = "num_full",
}
  , order by = "num_full DESC"
}
table#1 {
 table#2 {
   ["name"] = "Eddy SR, Griffiths-Jones SR, Mifsud W",
   ["number"] = "5335975",
 },
 table#3 {
   ["name"] = "Griffiths-Jones SR, Mifsud W, Gardner PP",
   ["number"] = "594154",
 },
 table#4 {
   ["name"] = "Bateman A",
   ["number"] = "493311",
 },
 table#5 {
   ["name"] = "Gardner PP",
   ["number"] = "383523",
 },
 table#6 {
   ["name"] = "Bateman A",
   ["number"] = "324644",
 },
 table#7 {
   ["name"] = "Griffiths-Jones SR",
   ["number"] = "278378",
 },
 table#8 {
   ["name"] = "Griffiths-Jones SR, Gardner PP",
   ["number"] = "204442",
 },
 table#9 {
   ["name"] = "Wilkinson A",
   ["number"] = "186514",
 },
 table#10 {
   ["name"] = "Gutell RR, Nawrocki E",
   ["number"] = "107465",
 },
 table#11 {
   ["name"] = "Gutell RR, Gardner PP, Nawrocki E",
   ["number"] = "75755",
 },

}
"(no error)"

MongoDB aggregate
mw.ext.externaldata.getDbData {
    from = "zips"
  , db = "mongo"
  , data = table#1 {
  ["pop"] = "totalPop",
  ["state"] = "_id",
}
  , aggregate = "[\
   { \"$group\": { \"_id\": \"$state\", \"totalPop\": { \"$sum\": \"$pop\" } } },\
   { \"$match\": { \"totalPop\": { \"$gte\": 5000000 } } }\
]\
"
  , order by = "totalPop DESC"
}
"(error)"

"table#1 {\

 [\"205308097fc119ba310a6fb8c2672be1\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует server.\",\
 [\"81898f4b59924b224881ff32a6247746\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует user/user file.\",\
 [\"ba091316401d88298a61c91d65dd0ce3\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует name.\",\
 [\"eee0a40cb9f564ab5fe302f76988f7fa\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует type.\",\

}"

MongoDB find
mw.ext.externaldata.getDbData {
    where = table#1 {
  ["state"] = "NY",
}
  , from = "zips"
  , db = "mongo"
  , limit = 10
  , data = table#1 {
  ["city"] = "city",
  ["id"] = "_id",
  ["loc"] = "loc",
  ["pop"] = "pop",
  ["state"] = "state",
}
  , order by = "pop DESC"
}
"(error)"

"table#1 {\

 [\"205308097fc119ba310a6fb8c2672be1\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует server.\",\
 [\"81898f4b59924b224881ff32a6247746\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует user/user file.\",\
 [\"ba091316401d88298a61c91d65dd0ce3\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует name.\",\
 [\"eee0a40cb9f564ab5fe302f76988f7fa\"] = \"В настройках вики неполная информация для БД с ID mongo. Отсутствует type.\",\

}"

mw.ext.externaldata.getLdapData
One entry
mw.ext.externaldata.getLdapData {
    data = table#1 {
  ["class"] = "objectClass",
  ["email"] = "mail",
  ["name"] = "uid",
  ["phone"] = "telephoneNumber",
}
  , domain = "example"
  , filter = "(sn=training)"
}
"(error)"

"table#1 {\

 [\"4315e62ddd2c5cc82e92f5bd74e0c80b\"] = \"Псевдодомен LDAP example не определён.\",\

}"

All entries
mw.ext.externaldata.getLdapData {
    "all"
  , data = table#1 {
  ["email"] = "mail",
  ["name"] = "cn",
  ["phone"] = "telephoneNumber",
}
  , domain = "example"
  , filter = "(objectClass=person)"
}
"(error)"

"table#1 {\

 [\"4315e62ddd2c5cc82e92f5bd74e0c80b\"] = \"Псевдодомен LDAP example не определён.\",\

}"

mw.ext.externaldata.getWebData
HTML with CSS
mw.ext.externaldata.getWebData {
    url = "https://www.apn.ru/index.php?do=authors&author=637"
  , data = "url=div.left_cell>h2>a.attr(href),title=div.left_cell>h2>a,date=div.left_cell>ul>li:nth-of-type(2)"
  , format = "HTML"
}
table#1 {

}
"(no error)"

JSON with JSONPath
mw.ext.externaldata.getWebData {
    use jsonpath = true
  , url = "https://discoursedb.org/w/extensions/ExternalData/nara.json"
  , data = table#1 {
  ["Num"] = "$.phoneNumbers[:].number",
}
  , format = "json"
}
table#1 {
 table#2 {
   ["Num"] = "0123-4567-8888",
 },
 table#3 {
   ["Num"] = "0123-4567-8910",
 },

}
"(no error)"

HTML with CSS. Data as a table
mw.ext.externaldata.getWebData {
    url = "https://expert.ru/avtory/konstantin_pakhunov/"
  , data = table#1 {
  ["title"] = "article h2>a",
  ["url"] = "article h2>a.attr(href)",
}
  , format = "HTML"
}
table#1 {

}
"(no error)"

XML
mw.ext.externaldata.getWebData {
    url = "http://producthelp.sdl.com/SDL%20Trados%20Studio/client_en/sample.xml"
  , data = "salutation=salutation,address=address,url=weblink,retrieved=__time"
  , format = "XML"
}
table#1 {
 table#2 {
   ["address"] = "Smith & Company Ltd.",
   ["retrieved"] = 1734234157,
   ["salutation"] = "Dear Daniel,",
   ["url"] = "http://www.smith-company-ltd.com",
 },
 table#3 {
   ["address"] = "Smithtown",
 },
 table#4 {
   ["address"] = "http://www.smith-company-ltd.com/logo.jpg",
 },
 ["retrieved"] = 1734234157,
 ["salutation"] = "Dear Daniel,",
 ["url"] = "http://www.smith-company-ltd.com",

}
"(no error)"

HTML with XPath
mw.ext.externaldata.getWebData {
    "use xpath"
  , url = "https://expert.ru/avtory/konstantin_pakhunov/"
  , data = "title=//article//h2/a,url=//article//h2/a/@href"
  , format = "HTML"
}
table#1 {

}
"(no error)"

CSV
mw.ext.externaldata.getWebData {
    url = "https://discoursedb.org/wiki/Special:GetData/Fruits_data"
  , data = "name=Name,color=Color,shape=Shape"
  , format = "CSV with header"
}
table#1 {
 table#2 {
   ["color"] = "Red or green",
   ["name"] = "Apple",
   ["shape"] = "Round",
 },
 table#3 {
   ["color"] = "Yellow",
   ["name"] = "Banana",
   ["shape"] = "Oblong",
 },
 table#4 {
   ["color"] = "Orange",
   ["name"] = "Orange",
   ["shape"] = "Round",
 },
 table#5 {
   ["color"] = "Yellow",
   ["name"] = "Pear",
   ["shape"] = "Pear-shaped",
 },

}
"(no error)"

CSV with header
mw.ext.externaldata.getWebData {
    url = "https://discoursedb.org/GermanyCSV.txt"
  , data = "bordered countries=Borders,population=Population,area=Area,capital=Capital"
  , format = "CSV with header"
}
table#1 {
 table#2 {
   ["area"] = "357,050 km²",
   ["bordered countries"] = "Austria,Belgium,Czech Republic,Denmark,France,Luxembourg,Netherlands,Poland,Switzerland",
   ["capital"] = "Berlin",
   ["population"] = "82,411,001",
 },
 ["area"] = "357,050 km²",
 ["bordered countries"] = "Austria,Belgium,Czech Republic,Denmark,France,Luxembourg,Netherlands,Poland,Switzerland",
 ["capital"] = "Berlin",
 ["population"] = "82,411,001",

}
"(no error)"

XML with XPath
mw.ext.externaldata.getWebData {
    "use xpath"
  , url = "http://producthelp.sdl.com/SDL%20Trados%20Studio/client_en/sample.xml"
  , data = "salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblink,retrieved=__time"
  , format = "XML"
}
table#1 {
 table#2 {
   ["address"] = "Smithtown",
   ["maxlength"] = "40",
   ["retrieved"] = "1734234157",
   ["salutation"] = "Dear Daniel,",
   ["url"] = "http://www.smith-company-ltd.com",
 },
 ["address"] = "Smithtown",
 ["maxlength"] = "40",
 ["retrieved"] = "1734234157",
 ["salutation"] = "Dear Daniel,",
 ["url"] = "http://www.smith-company-ltd.com",

}
"(no error)"

See also Traditio:test/ED.