![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Creating Applications with Mozilla-Chapter 10. RDF, RDF Tools, and the Content Model-P5
Số trang: 16
Loại file: pdf
Dung lượng: 31.11 KB
Lượt xem: 1
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Tham khảo tài liệu creating applications with mozilla-chapter 10. rdf, rdf tools, and the content model-p5, công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Creating Applications with Mozilla-Chapter 10. RDF, RDF Tools, and the Content Model-P5 Chapter 10. RDF, RDF Tools, and the Content Model-P510.1.3.2. Root resourceIn Example 10-11, everything you need to display a datasourcedynamically is present. The only difference between this dynamicallygenerated version and a static RDF-based template is thedatasources=rdf:null, which specifies that the template doesnot refer to an actual datasource. Data that is edited, rearranged, orchanged in a different way is often displayed dynamically in the UIwith templates in this manner.10.5. JSLib RDF FilesWorking with actual RDF files is not easy. However, JSLib(http://jslib.mozdev.org) provides an RDF file library that can help youdevelop an RDF-based application. The library provides many types of errorchecking, as well as a friendly abstraction away from the RDF/XMLinterfaces of Mozilla (see Section 10.3.11, later in this chapter). Example 10-12 shows some common uses of the RDFFile class in JSLib. Thisfunctionality can be used in situations in which you have data in RDF thatyou want to pull out manually and use piece by piece (rather than as awhole datasource in a template).Example 10-12. Creating and modifying an RDF file using JSLibvar rdfFileURL = chrome://jarfly/content/jar.rdf;var gTreeBody = null;var gListbox = null;var gRDF = null;function onload( ){ fileUtils = new FileUtils( ); path = fileUtils.chrome_to_path(rdfFileURL); if(navigator.platform == Win32) { path = path.replace(/\//g,\\); // Only needed on Windows, until JSLib is fixed } gRDF = newRDFFile(path,jar:flies,http://mozdev.org/fly-rdf#); gTreeBody = document.getElementById(tb); gTreeBody.database.AddDataSource(gRDF.dsource); gListbox = document.getElementById(list); gListbox.database.AddDataSource(gRDF.dsource); rebuildLists( );}function rebuildLists( ){ gTreeBody.builder.rebuild( ); gListbox.builder.rebuild( );}function update( ){ name =document.getElementById(nameField).value; color =document.getElementById(colorField).value; quantity =document.getElementById(quantityField).value; seqNumber = -1; del = false; replace = false; if(document.getElementById(delete).checked) del = true; if(document.getElementById(replace).checked) replace = true; var seqLength = 0; if(gRDF.doesSeqExist(types)) { seqLength =gRDF.getSeqSubNodes(types).length; //if(del)gRDF.removeSeq(types,false); } else gRDF.addSeq(types); for(i=0;i gRDF.setAttribute(item,color,color); if(quantity!=) { gRDF.setAttribute(item,quantity,quantity);gRDF.setAttribute(item,dead,calcDead(quantity,replace)); } if(!del) gRDF.addNode(item); else gRDF.removeNode(item); gRDF.flush( ); onload( );}function calcDead(quantity,replace){ if(!replace) { v = parseInt( (quantity * Math.random( )) *0.13 ); return (v.toString( )); } else return 0;}function changeC(color){document.getElementById(colorField).value=color;}function changeQ(quantity){document.getElementById(quantityField).value=quantity;}This example contains a datasource that represents a collection of flies.These flies are built up dynamically with JavaScript objects from the RDFlibrary, which represent the datasource itself (gRDF = new RDFFile),methods that view and update the data(if(gRDF.getAttribute(tempItem,name)==name), andutilities that make work with RDF files easier (path =fileUtils.chrome_to_path(rdfFileURL)).Example 10-13 initializes and updates a file after it changes.Example 10-13. Initializationvar rdfFileURL = chrome://jarfly/content/jar.rdf;var gTreeBody = null;var gListbox = null;var gRDF = null;function onload( ){ fileUtils = new FileUtils( ); path = fileUtils.chrome_to_path(rdfFileURL); if(navigator.platform == Win32) { path = path.replace(/\//g,\\); // Only needed on Windows, until JSLib is fixed } gRDF = newRDFFile(path,jar:flies,http://mozdev.org/fly-rdf#);In Example 10-13, the file URL is set to an RDF file in the chrome area.Note that both a and a , which display the same datain different ways, will be updated with the same datasource. The onloadfunction is called after the main XUL document is loaded. A class calledFileUtils is initialized, which will create a path to the RDF file. If thefile doesnt already exist, JSLib automatically creates it.Finally, the RDFFile is created by using the path and a root resourceidentifier, and the xFly namespace is used for the data references. Example10-14 shows that the RDF file is ready to have its data added and deleted.Example 10-14. Data updatingfunction update( ){ ... var seqLength = 0; if(gRDF.doesSeqExist(types)) { seqLength =gRDF.getSeqSubNodes(types).length; } else gRDF.addSeq(types); for(i=0;i if(seqNumber == -1) { item = types:_ + (seqLength+1); gRDF.setAttribute(item,name,name); gRDF.setAttribute(item,number,seqLength+1); } else { item = types:_ + seqNumber; gRDF.setAttribute(item,number,seqNumber); } if(color!=) gRDF.setAttribute(item,color,color); if(quantity!=) { gRDF.setAttribute(item,quantity,quantity);gRDF.setAttribute(item,dead,calcDead(quantity,replace)); } if(!del) gRDF.addNode(item); else gRDF.removeNode(item); gRDF.flush( ); onload( );Example 10-14 contains a modified version of the update function. First,the function checks to see if a sequence called types is in the RDF file. I ...
Nội dung trích xuất từ tài liệu:
Creating Applications with Mozilla-Chapter 10. RDF, RDF Tools, and the Content Model-P5 Chapter 10. RDF, RDF Tools, and the Content Model-P510.1.3.2. Root resourceIn Example 10-11, everything you need to display a datasourcedynamically is present. The only difference between this dynamicallygenerated version and a static RDF-based template is thedatasources=rdf:null, which specifies that the template doesnot refer to an actual datasource. Data that is edited, rearranged, orchanged in a different way is often displayed dynamically in the UIwith templates in this manner.10.5. JSLib RDF FilesWorking with actual RDF files is not easy. However, JSLib(http://jslib.mozdev.org) provides an RDF file library that can help youdevelop an RDF-based application. The library provides many types of errorchecking, as well as a friendly abstraction away from the RDF/XMLinterfaces of Mozilla (see Section 10.3.11, later in this chapter). Example 10-12 shows some common uses of the RDFFile class in JSLib. Thisfunctionality can be used in situations in which you have data in RDF thatyou want to pull out manually and use piece by piece (rather than as awhole datasource in a template).Example 10-12. Creating and modifying an RDF file using JSLibvar rdfFileURL = chrome://jarfly/content/jar.rdf;var gTreeBody = null;var gListbox = null;var gRDF = null;function onload( ){ fileUtils = new FileUtils( ); path = fileUtils.chrome_to_path(rdfFileURL); if(navigator.platform == Win32) { path = path.replace(/\//g,\\); // Only needed on Windows, until JSLib is fixed } gRDF = newRDFFile(path,jar:flies,http://mozdev.org/fly-rdf#); gTreeBody = document.getElementById(tb); gTreeBody.database.AddDataSource(gRDF.dsource); gListbox = document.getElementById(list); gListbox.database.AddDataSource(gRDF.dsource); rebuildLists( );}function rebuildLists( ){ gTreeBody.builder.rebuild( ); gListbox.builder.rebuild( );}function update( ){ name =document.getElementById(nameField).value; color =document.getElementById(colorField).value; quantity =document.getElementById(quantityField).value; seqNumber = -1; del = false; replace = false; if(document.getElementById(delete).checked) del = true; if(document.getElementById(replace).checked) replace = true; var seqLength = 0; if(gRDF.doesSeqExist(types)) { seqLength =gRDF.getSeqSubNodes(types).length; //if(del)gRDF.removeSeq(types,false); } else gRDF.addSeq(types); for(i=0;i gRDF.setAttribute(item,color,color); if(quantity!=) { gRDF.setAttribute(item,quantity,quantity);gRDF.setAttribute(item,dead,calcDead(quantity,replace)); } if(!del) gRDF.addNode(item); else gRDF.removeNode(item); gRDF.flush( ); onload( );}function calcDead(quantity,replace){ if(!replace) { v = parseInt( (quantity * Math.random( )) *0.13 ); return (v.toString( )); } else return 0;}function changeC(color){document.getElementById(colorField).value=color;}function changeQ(quantity){document.getElementById(quantityField).value=quantity;}This example contains a datasource that represents a collection of flies.These flies are built up dynamically with JavaScript objects from the RDFlibrary, which represent the datasource itself (gRDF = new RDFFile),methods that view and update the data(if(gRDF.getAttribute(tempItem,name)==name), andutilities that make work with RDF files easier (path =fileUtils.chrome_to_path(rdfFileURL)).Example 10-13 initializes and updates a file after it changes.Example 10-13. Initializationvar rdfFileURL = chrome://jarfly/content/jar.rdf;var gTreeBody = null;var gListbox = null;var gRDF = null;function onload( ){ fileUtils = new FileUtils( ); path = fileUtils.chrome_to_path(rdfFileURL); if(navigator.platform == Win32) { path = path.replace(/\//g,\\); // Only needed on Windows, until JSLib is fixed } gRDF = newRDFFile(path,jar:flies,http://mozdev.org/fly-rdf#);In Example 10-13, the file URL is set to an RDF file in the chrome area.Note that both a and a , which display the same datain different ways, will be updated with the same datasource. The onloadfunction is called after the main XUL document is loaded. A class calledFileUtils is initialized, which will create a path to the RDF file. If thefile doesnt already exist, JSLib automatically creates it.Finally, the RDFFile is created by using the path and a root resourceidentifier, and the xFly namespace is used for the data references. Example10-14 shows that the RDF file is ready to have its data added and deleted.Example 10-14. Data updatingfunction update( ){ ... var seqLength = 0; if(gRDF.doesSeqExist(types)) { seqLength =gRDF.getSeqSubNodes(types).length; } else gRDF.addSeq(types); for(i=0;i if(seqNumber == -1) { item = types:_ + (seqLength+1); gRDF.setAttribute(item,name,name); gRDF.setAttribute(item,number,seqLength+1); } else { item = types:_ + seqNumber; gRDF.setAttribute(item,number,seqNumber); } if(color!=) gRDF.setAttribute(item,color,color); if(quantity!=) { gRDF.setAttribute(item,quantity,quantity);gRDF.setAttribute(item,dead,calcDead(quantity,replace)); } if(!del) gRDF.addNode(item); else gRDF.removeNode(item); gRDF.flush( ); onload( );Example 10-14 contains a modified version of the update function. First,the function checks to see if a sequence called types is in the RDF file. I ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật máy tính công nghệ thông tin tin học quản trị mạng computer networkTài liệu liên quan:
-
52 trang 439 1 0
-
24 trang 366 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 329 0 0 -
Làm việc với Read Only Domain Controllers
20 trang 321 0 0 -
74 trang 309 0 0
-
96 trang 305 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 299 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 291 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 291 1 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 278 0 0