Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gxml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Canek Peláez Valdés
Gxml
Commits
d4c68d4e
Commit
d4c68d4e
authored
11 years ago
by
Richard Schwarting
Browse files
Options
Downloads
Patches
Plain Diff
examples/js: rename several examples, add new ones
parent
152e5267
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/js/document_factory.js
+36
-0
36 additions, 0 deletions
examples/js/document_factory.js
examples/js/document_properties.js
+19
-0
19 additions, 0 deletions
examples/js/document_properties.js
with
55 additions
and
0 deletions
examples/js/document_factory.js
0 → 100755
+
36
−
0
View file @
d4c68d4e
#!/usr/bin/gjs
const
GXml
=
imports
.
gi
.
GXml
;
let
doc
=
GXml
.
Document
.
new
();
/* <book></book> */
let
elem
=
doc
.
create_element
(
"
book
"
);
print
(
"
Book element:
"
+
elem
.
to_string
(
false
,
0
));
let
docfragment
=
doc
.
create_document_fragment
();
print
(
"
Fragment:
"
+
docfragment
.
to_string
(
false
,
0
));
/* <book>Between the book tags is text!</book> */
let
text
=
doc
.
create_text_node
(
"
Between the book tags is text!
"
);
print
(
"
Text:
"
+
text
.
to_string
(
false
,
0
));
/* <book><!-- comment: I really like this book -->The fault in our stars</book> */
let
comment
=
doc
.
create_comment
(
"
comment: I really like this book
"
);
print
(
"
Comment:
"
+
comment
.
to_string
(
false
,
0
));
/* <![CDATA[non-XML data like code or special entities]]> */
let
cdata
=
doc
.
create_cdata_section
(
"
non-XML data like code or special entities
"
);
print
(
"
CDATA section:
"
+
cdata
.
to_string
(
false
,
0
));
/* <?xml href="style.xsl" type="text/xml"?> */
let
pi
=
doc
.
create_processing_instruction
(
"
xml
"
,
"
href=
\"
style.xsl
\"
type=
\"
text/xml
\"
"
);
print
(
"
Processing Instruction:
"
+
pi
.
to_string
(
false
,
0
));
/* <element id=""> */
let
attr
=
doc
.
create_attribute
(
"
id
"
);
print
(
"
Attribute:
"
+
attr
.
to_string
(
false
,
0
));
/* ' (for an apostrophe, ') */
let
entref
=
doc
.
create_entity_reference
(
"
apos
"
);
print
(
"
Entity reference:
"
+
entref
.
to_string
(
false
,
0
));
This diff is collapsed.
Click to expand it.
examples/js/document_properties.js
0 → 100755
+
19
−
0
View file @
d4c68d4e
#!/usr/bin/gjs
const
GXml
=
imports
.
gi
.
GXml
;
let
xml
=
"
<?xml version=
\"
1.0
\"
?><!DOCTYPE bookshelf><Bookshelf><Owner fullname=
\"
John Green
\"
/><Books><Book author=
\"
John Green
\"
title=
\"
The Fault in Our Stars
\"
/><Book author=
\"
Jane Austen
\"
title=
\"
Pride & Prejudice
\"
/><Book author=
\"
J.D. Salinger
\"
title=
\"
Nine Stories
\"
/></Books></Bookshelf>
"
;
let
doc
=
GXml
.
Document
.
from_string
(
xml
);
print
(
"
A document's node_name is:
"
+
doc
.
node_name
+
"
(which should always be '#document')
\n
"
);
print
(
"
The document's doctype is:
"
+
doc
.
doctype
.
name
+
"
(which should be 'bookshelf')
\n
"
);
let
impl
=
doc
.
implementation
;
print
(
"
GXml's implementation that created this document has the features
\n
xml 1.0?
"
+
(
impl
.
has_feature
(
"
xml
"
,
"
1.0
"
)
?
"
true
"
:
"
false
"
)
+
"
(should be true)
\n
html?
"
+
(
impl
.
has_feature
(
"
html
"
,
null
)
?
"
true
"
:
"
false
"
)
+
"
(should be false)
\n
"
);
print
(
"
Document has root element with name:
"
+
doc
.
document_element
.
node_name
+
"
(should be 'Bookshelf')
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment