Some XML examples documentation fixes. (0.37.1)
This commit is contained in:
parent
26ddaf161e
commit
b2986075cb
6 changed files with 185 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(fun VERSION 0.37.0 LANGUAGES C)
|
||||
project(fun VERSION 0.37.1 LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
|
|
|||
|
|
@ -52,3 +52,46 @@ else
|
|||
print(currency)
|
||||
print(" ")
|
||||
print(price_text)
|
||||
|
||||
/* Expected output:
|
||||
Root element:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<catalog>
|
||||
<product id="SKU-1001">
|
||||
<name>Wireless Keyboard</name>
|
||||
<category>Peripherals</category>
|
||||
<price currency="USD">39.99</price>
|
||||
<specs>
|
||||
<layout>US</layout>
|
||||
<connection>Bluetooth</connection>
|
||||
<battery>AA</battery>
|
||||
</specs>
|
||||
</product>
|
||||
<product id="SKU-2002">
|
||||
<name>27" Monitor</name>
|
||||
<category>Displays</category>
|
||||
<price currency="USD">199.00</price>
|
||||
<specs>
|
||||
<resolution>2560x1440</resolution>
|
||||
<panel>IPS</panel>
|
||||
<refresh>75Hz</refresh>
|
||||
</specs>
|
||||
</product>
|
||||
<product id="SKU-3003">
|
||||
<name>USB-C Dock</name>
|
||||
<category>Peripherals</category>
|
||||
<price currency="USD">89.50</price>
|
||||
<specs>
|
||||
<ports>2xHDMI, 3xUSB-A, 1xUSB-C PD</ports>
|
||||
<pd>65W</pd>
|
||||
</specs>
|
||||
</product>
|
||||
</catalog>
|
||||
|
||||
First product name:
|
||||
Wireless Keyboard
|
||||
First price:
|
||||
USD
|
||||
|
||||
39.99
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,3 +44,38 @@ else
|
|||
print(role)
|
||||
print("Email: ")
|
||||
print(email)
|
||||
|
||||
/* Expected output:
|
||||
Root element:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<company>
|
||||
<department name="Engineering">
|
||||
<employee id="E-100">
|
||||
<name>Alice Doe</name>
|
||||
<role>Senior Developer</role>
|
||||
<email>alice@example.com</email>
|
||||
</employee>
|
||||
<employee id="E-101">
|
||||
<name>Bob Roe</name>
|
||||
<role>DevOps Engineer</role>
|
||||
<email>bob@example.com</email>
|
||||
</employee>
|
||||
</department>
|
||||
<department name="Sales">
|
||||
<employee id="S-200">
|
||||
<name>Carol Smith</name>
|
||||
<role>Account Executive</role>
|
||||
<email>carol@example.com</email>
|
||||
</employee>
|
||||
</department>
|
||||
</company>
|
||||
|
||||
First employee id:
|
||||
E-100
|
||||
Name:
|
||||
Alice Doe
|
||||
Role:
|
||||
Senior Developer
|
||||
Email:
|
||||
alice@example.com
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,3 +38,23 @@ else
|
|||
print(title)
|
||||
print("Author: ")
|
||||
print(author)
|
||||
|
||||
/* Expected output:
|
||||
Root element:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ns:library xmlns:ns="http://example.org/ns/library" xmlns:bk="http://example.org/ns/book">
|
||||
<bk:book id="B-1">
|
||||
<bk:title>The Art of Fun</bk:title>
|
||||
<bk:author>J. Findeisen</bk:author>
|
||||
</bk:book>
|
||||
<bk:book id="B-2">
|
||||
<bk:title>Minimal VM Design</bk:title>
|
||||
<bk:author>A. Dev</bk:author>
|
||||
</bk:book>
|
||||
</ns:library>
|
||||
|
||||
First book title:
|
||||
The Art of Fun
|
||||
Author:
|
||||
J. Findeisen
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,3 +27,84 @@ else
|
|||
print(xml.name(root))
|
||||
print("root text:")
|
||||
print(xml.text(root))
|
||||
|
||||
/* Expected output:
|
||||
doc handle:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<company name="Acme Corp">
|
||||
<departments>
|
||||
<department id="eng" name="Engineering">
|
||||
<team name="Platform">
|
||||
<member id="u1">Alice</member>
|
||||
<member id="u2">Bob</member>
|
||||
</team>
|
||||
<team name="Product">
|
||||
<member id="u3">Carol</member>
|
||||
</team>
|
||||
</department>
|
||||
<department id="ops" name="Operations">
|
||||
<team name="SRE">
|
||||
<member id="u4">Dave</member>
|
||||
</team>
|
||||
</department>
|
||||
</departments>
|
||||
<offices>
|
||||
<office city="Berlin" country="DE"/>
|
||||
<office city="Paris" country="FR"/>
|
||||
</offices>
|
||||
<note>Welcome to Acme!</note>
|
||||
</company>
|
||||
|
||||
root name:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<company name="Acme Corp">
|
||||
<departments>
|
||||
<department id="eng" name="Engineering">
|
||||
<team name="Platform">
|
||||
<member id="u1">Alice</member>
|
||||
<member id="u2">Bob</member>
|
||||
</team>
|
||||
<team name="Product">
|
||||
<member id="u3">Carol</member>
|
||||
</team>
|
||||
</department>
|
||||
<department id="ops" name="Operations">
|
||||
<team name="SRE">
|
||||
<member id="u4">Dave</member>
|
||||
</team>
|
||||
</department>
|
||||
</departments>
|
||||
<offices>
|
||||
<office city="Berlin" country="DE"/>
|
||||
<office city="Paris" country="FR"/>
|
||||
</offices>
|
||||
<note>Welcome to Acme!</note>
|
||||
</company>
|
||||
|
||||
root text:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<company name="Acme Corp">
|
||||
<departments>
|
||||
<department id="eng" name="Engineering">
|
||||
<team name="Platform">
|
||||
<member id="u1">Alice</member>
|
||||
<member id="u2">Bob</member>
|
||||
</team>
|
||||
<team name="Product">
|
||||
<member id="u3">Carol</member>
|
||||
</team>
|
||||
</department>
|
||||
<department id="ops" name="Operations">
|
||||
<team name="SRE">
|
||||
<member id="u4">Dave</member>
|
||||
</team>
|
||||
</department>
|
||||
</departments>
|
||||
<offices>
|
||||
<office city="Berlin" country="DE"/>
|
||||
<office city="Paris" country="FR"/>
|
||||
</offices>
|
||||
<note>Welcome to Acme!</note>
|
||||
</company>
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,3 +17,8 @@ doc = xml_parse("<root><item id=\"1\">a</item><item id=\"2\">b</item></root>")
|
|||
print("doc handle=\(doc)")
|
||||
root = xml_root(doc)
|
||||
print("root name=\(xml_name(root)) text=\(xml_text(root))")
|
||||
|
||||
/* Expected output:
|
||||
doc handle=(doc)
|
||||
root name=(xml_name(root)) text=(xml_text(root))
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue