Collection and sharing of, interview questions and answers asked in various interviews, faqs and articles.....
what is the difference between Convert.toString and .toString ()?
int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));
We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what is the
difference. The basic difference between them is “Convert” function handles NULLS while
“i.ToString()” does not it will throw a NULL reference exception error. So as a good coding
practice using “convert” is always safe.
How to prevent my .NET DLL to be decompiled?
easily decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for
.NET which is a third party. Secondly, there are many third party tools, which make this
decompiling process a click away. So any one can easily look in to your assemblies and reverse
engineer them back in to actual source code and understand some real good logic, which can
make it easy to crack your application.
The process by which you can stop this reverse engineering is using “obfuscation”. It is a
technique, which will foil the decompilers. Many third parties (XenoCode, Demeanor for .NET)
provide .NET obfuscation solution. Microsoft includes one that is Dotfuscator Community
Edition with Visual Studio.NET.
What is CODE Access security?
what resources it can use while running. Example CAS will allow an application to read but not
to write and delete a file or a resource from a folder..
what is the difference between System exceptions and Application
or can be generated by system. Application Exception serves as the base class for all applicationspecific
exception classes. It derives from Exception but does not provide any extended
functionality. You should derive your custom application exceptions from Application Exception.
Application exception is used when we want to define user-defined exception, while system
exception is all that is defined by .NET.
What is the difference between VB.NET and C#?
It is a subjective matter which language is best. Some like VB.NET’s natural style and some like
professional and terse C# syntaxes. Both use the same framework and speed is very much
equivalents. Still let us list down some major differences between them:-
Advantages VB.NET:-
• Has support for optional parameters that makes COM interoperability much easy.
• With Option Strict off late binding is supported.Legacy VB functionalities can be
used by using Microsoft.VisualBasic namespace.
• Has the WITH construct which is not in C#.
• The VB.NET parts of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very
large projects have found that the IDE slows down considerably as the project
gets larger.
Advantages of C#
• XML documentation is generated from source code but this is now been
incorporated in Whidbey.
• Operator overloading which is not in current VB.NET but is been introduced in
Whidbey.
• Use of this statement makes unmanaged resource disposal simple.
• Access to Unsafe code. This allows pointer arithmetic etc, and can improve
performance in some situations. However, it is not to be used lightly, as a lot of
the normal safety of C# is lost (as the name implies).This is the major difference
that you can access unmanaged code in C# and not in VB.NET.
What is concept of Boxing and Unboxing ?
value type to a reference type it’s termed as boxing. Unboxing is just vice-versa. When an object
box is cast back to its original value type, the value is copied out of the box and into the
appropriate storage location.
Below is sample code of boxing and unboxing where integer data type are converted in to object
and then vice versa.
int i = 1;
object obj = i; // boxing
int j = (int) obj; // unboxing
What are Value types and Reference types?
Value types directly contain their data that are either allocated on the stack or allocated in-line in
a structure. So value types are actual data.
Reference types store a reference to the value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer types, or interface types. You can view
reference type as pointers to actual data.
Variables that are value types each have their own copy of the data, and therefore operations on
one variable do not affect other variables. Variables that are reference types can refer to the same
object; therefore, operations on one variable can affect the same object referred to by another
variable. All types derive from the System. Object base type.
(A) What are different types of JIT?
JIT compiler is a part of the runtime execution environment.
In Microsoft .NET there are three types of JIT compilers:
• Pre-JIT: - Pre-JIT compiles complete source code into native code in a single
compilation cycle. This is done at the time of deployment of the application.
• Econo-JIT: - Econo-JIT compiles only those methods that are called at runtime.
However, these compiled methods are removed when they are not required.
• Normal-JIT: - Normal-JIT compiles only those methods that are called at runtime.
These methods are compiled the first time they are called, and then they are stored in
cache. When the same methods are called again, the compiled code from cache is used
for execution.
What is reflection?
All .NET assemblies have metadata information stored about the types defined in modules. This
metadata information can be accessed by mechanism called as “Reflection”. System. Reflection
can be used to browse through the metadata information.
Using reflection, you can also dynamically invoke methods using System.Type.Invokemember.
Below is sample source code if needed you can also get this code from CD provided, go to
“Source code” folder in “Reflection Sample” folder.
Public Class Form1
Private Sub Form1_Load (ByVal sender As System. Object, ByVal e as
System.EventArgs) Handles MyBase.Load
Dim Pobjtype As Type
Dim PobjObject As Object
Dim PobjButtons As New Windows.Forms.Button ()
Pobjtype = PobjButtons.GetType ()
For Each PobjObject in Pobjtype.GetMembers
LstDisplay.Items.Add (PobjObject.ToString ())
Next
End Sub
End Class
What is garbage collection?
How do I find the overall database size?
select sum(bytes)/1024/1024 "Meg" from dba_data_files;
To get the size of all TEMP files:
select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
To get the size of the on-line redo-logs:
select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
Putting it all together into a single query:
select a.data_size+b.temp_size+c.redo_size "total_size"
from ( select sum(bytes) data_size
from dba_data_files ) a,
( select nvl(sum(bytes),0) temp_size
from dba_temp_files ) b,
( select sum(bytes) redo_size
from sys.v_$log ) c;
Can one resize tablespaces and data files?
To add more space to a tablespace, one can simply add another file to it. Example:
ALTER TABLESPACE USERS ADD DATAFILE '/oradata/orcl/users1.dbf' SIZE 100M;
Resize datafiles
One can manually increase or decrease the size of a datafile from Oracle 7.2 using the following command:
ALTER DATABASE DATAFILE 'filename2' RESIZE 100M;
Because you can change the sizes of datafiles, you can add more space to your database without adding more datafiles. This is beneficial if you are concerned about reaching the maximum number of datafiles allowed in your database.
Manually reducing the sizes of datafiles allows you to reclaim unused space in the database. This is useful for correcting errors in estimations of space requirements.
Extend datafiles
Also, datafiles can be allowed to automatically extend if more space is required. Look at the following commands:
CREATE TABLESPACE pcs_data_ts
DATAFILE 'c:ora_appspcspcsdata1.dbf' SIZE 3M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE ( INITIAL 10240
NEXT 10240
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
ONLINE
PERMANENT;
ALTER DATABASE DATAFILE 1 AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
How does one see the uptime for a database?
SELECT to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') "DB Startup Time"
FROM sys.v_$instance;
Marco Bergman provided the following solution:
SELECT to_char(logon_time,'Dy dd Mon HH24:MI:SS') "DB Startup Time"
FROM sys.v_$session
WHERE sid=1 /* this is pmon */
/
Tarun Dua provided the following solution:
Check on operating system level when the PMON process was stated (UNIX/ LINUX only):
ps -ef | grep pmon
Users still running on Oracle 7 can try one of the following queries:
column STARTED format a18 head 'STARTUP TIME'
select C.INSTANCE,
to_date(JUL.VALUE, 'J')
|| to_char(floor(SEC.VALUE/3600), '09' )
|| ':'
-- || substr (to_char(mod(SEC.VALUE/60, 60), '09'), 2, 2)
|| substr (to_char(floor(mod(SEC.VALUE/60, 60)), '09'), 2, 2)
|| '.'
|| substr (to_char(mod(SEC.VALUE, 60), '09'), 2, 2) STARTED
from SYS.V_$INSTANCE JUL,
SYS.V_$INSTANCE SEC,
SYS.V_$THREAD C
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
select to_date(JUL.VALUE, 'J')
|| to_char(to_date(SEC.VALUE, 'SSSSS'), ' HH24:MI:SS') STARTED
from SYS.V_$INSTANCE JUL,
SYS.V_$INSTANCE SEC
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
select to_char(to_date(JUL.VALUE, 'J') + (SEC.VALUE/86400), -- Return a DATE
'DD-MON-YY HH24:MI:SS') STARTED
from V$INSTANCE JUL,
V$INSTANCE SEC
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
Can one rename a tablespace?
ALTER TABLESPACE ts1 RENAME TO ts2;
However, you must adhere to the following restrictions:
• COMPATIBILITY must be set to at least 10.0.1
• Cannot rename SYSTEM or SYSAUX
• Cannot rename an offline tablespace
• Cannot rename a tablespace that contains offline datafiles
For older releases, use the following workaround:
• Export all of the objects from the tablespace
• Drop the tablespace including contents
• Recreate the tablespace
• Import the objects
Can one rename a database user (schema)?
-->Do a user-level export of user A
-->create new user B
-->import system/manager fromuser=A touser=B
-->drop user A
How does one rename a database?
Follow these steps to rename a database:
==>Start by making a full database backup of your database (in case you need to restore if this procedure is not working).
==>Execute this command from sqlplus while connected to 'SYS AS SYSDBA':
ALTER DATABASE BACKUP CONTROLFILE TO TRACE RESETLOGS;
==>Locate the latest dump file in your USER_DUMP_DEST directory (show parameter USER_DUMP_DEST) - rename it to something like dbrename.sql.
==>Edit dbrename.sql, remove all headers and comments, and change the database's name. Also change "CREATE CONTROLFILE REUSE ..." to "CREATE CONTROLFILE SET ...".
Shutdown the database (use SHUTDOWN NORMAL or IMMEDIATE, don't ABORT!) and run dbrename.sql.
==>Rename the database's global name:
ALTER DATABASE RENAME GLOBAL_NAME TO new_db_name;
What database aspects should be monitored?
One should implement a monitoring system to constantly monitor the following aspects of a database. This can be achieved by writing custom scripts, implementing Oracle's Enterprise Manager, or buying a third-party monitoring product. If an alarm is triggered, the system should automatically notify the DBA (e-mail, text, etc.) to take appropriate action.
Infrastructure availability:
Is the database up and responding to requests
Are the listeners up and responding to requests
Are the Oracle Names and LDAP Servers up and responding to requests
Are the Application Servers up and responding to requests
Etc.
Things that can cause service outages:
Is the archive log destination filling up?
Objects getting close to their max extents
Tablespaces running low on free space/ Objects what would not be able to extend
User and process limits reached
Etc.
What database block size should I use?
If you are using a volume manager, consider your "operating system block size" to be 8K. This is because volume manager products use 8K blocks (and this is not configurable).
How does one create a new database?
One can also create databases manually using scripts. This option, however, is falling out of fashion as it is quite involved and error prone. Look at this example for creating an Oracle 9i or higher database:
CONNECT SYS AS SYSDBA
ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u01/oradata/';
ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_1='/u02/oradata/';
ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_2='/u03/oradata/';
CREATE DATABASE;
How will Windows Communication Foundation change the way developers build applications?
What is Windows Communication Foundation?
What is Service-Orientation and how is it related to Windows Communication Foundation?
Service Orientation is a specific set of architectural principles for building loosely coupled services that help developers maximize the return on your application investments over time. The services have explicit boundaries, are autonomous, share schema and contracts, and determine compatibility based on policy. Applications based on these principles provide benefits in maintainability, reusability, and manageability of connected systems. Windows Communication Foundation is the first programming model built from the ground up for building service-oriented applications.
Why is service orientation important?
Does service-oriented development conflict with object-oriented development?
No. Service-oriented development complements object-oriented (OO) development. Object-oriented development continues to fulfill an important role in the internal design of services. Service-orientation deals with how to interconnect services to build connected systems. To use an architecture analogy, OO development addresses the architecture within a single building (a service), while service-orientation addresses the issues around city planning (a system).
How will Windows Communication Foundation make service-oriented development easier?
Today, it is difficult to build service-oriented applications due to the lack of an intuitive service-oriented programming model. Web services provide a great start, but lack support for more advanced communication, including secure and reliable transacted services. Windows Communication Foundation provides both an intuitive service-oriented programming model and the advanced functionality to create service-oriented applications that interoperate across organizational and platform boundaries.
Will Windows Communication Foundation applications interoperate with Web services built with other technologies?
What specifications will Windows Communication Foundation support?
Windows Communication Foundation will support a broad range of Web services standards, including basic standards (XML, XSD, XPath, SOAP, WSDL) and advanced standards and specifications that comprise the WS-* architecture. These include WS-Addressing, WS-Policy, WS-Security, WS-Trust, WS-SecureConversation, WS-ReliableMessaging, WS-AtomicTransaction, WS-Coordination, WS-Policy, and MTOM.
What are activities in WWF?
An activity can perform a single action, such as writing a value to a database, or it can be a composite activity and consist of a set of activities. Activities have two types of behavior: runtime and design time. The runtime behavior specifies the actions upon execution. The design time behavior controls the appearance of the activity and its interaction while being displayed within the designer.
What is password fatigue?
In Terms of WCF, what do you understand by metadata of a service?
The metadata of a service describes the characteristics of the service that an external entity needs to understand to communicate with the service. Metadata can be consumed by the Service Model Metadata Utility Tool ( Svcutil.exe) to generate a WCF client and accompanying configuration that a client application can use to interact with the service.
The metadata exposed by the service includes XML schema documents, which define the data contract of the service, and WSDL documents, which describe the methods of the service.
What is a fault contract?
What is a message contract?
What is an operation contract?
In terms of WCF, What is binding?
In terms of WCF, What is an address?
In terms of WCF, What is an infrastructure endpoint?
In terms of WCF, What is an application endpoint?
In terms of WCF, What is an endpoint?
An WCF service is exposed to the world as a collection of endpoints.
In terms of WCF, What is a service?
In terms of WCF, What is a message?
What is a service contract ( In WCF) ?
Everything your consumer has to know is your service interface, and how to talk to it. In order to know this, both parts (service and consumer) have to share something that is called a Contract.
In WCF, there are 3 kinds of contracts: Service Contract, Data Contract and Message Contract.
A Service Contract describes what the service can do. It defines some properties about the service, and a set of actions called Operation Contracts. Operation Contracts are equivalent to web methods in ASMX technology
What is XBAP?
What is XAML ?
What contemporary computing problems WPF solves?
A primary goal of WPF is to address this challenge! By offering a consistent platform for these entire user interface aspects, WPF makes life simpler for developers. By providing a common foundation for desktop clients and browser clients, WPF makes it easier to build applications.
What contemporary computing problems WCS solves?
What are WCF features and what communication problems it solves?
Unification of Microsoft's communication technologies.
Support for cross-vendor interoperability, including reliability, security, and transactions.
Rich support for service orientation development
What Improvements does WCF offers over its earlier counterparts?
What is the .NET Framework 3.0 (formerly WinFX)?
The .NET Framework 3.0 is Microsoft's managed code programming model. It is a superset of the .NET Framework 2.0, combining .NET Framework 2.0 components with new technologies for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. In addition to the .NET Framework 2.0, it includes Windows Presentation Foundation (WPF), Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), and Windows CardSpace.
What happens to the WinFX technologies?
How does the .NET Framework 3.0 relate to the .NET Framework 2.0?
Will the name change be reflected in any of the existing .NET Framework 2.0 APIs, assemblies, or namespaces?
There will be no changes to any of the existing .NET Framework 2.0 APIs, assemblies, or namespaces. The applications that you've built on .NET Framework 2.0 will continue to run on the .NET Framework 3.0 just as they have before.
Which version of the Common Language Runtime (CLR) does the .NET Framework 3.0 use?
Why is the .NET Framework 3.0 a major version number of the .NET Framework if it uses the .NET Framework 2.0 runtime and compiler?
What is .Net Framework 3.0?
The Microsoft .NET Framework 3.0 (formerly WinFX), is the new managed code programming model for Windows.
It combines the power of the .NET Framework 2.0 with four new technologies: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), and Windows CardSpace (WCS, formerly "InfoCard").
Use the .NET Framework 3.0 today to build applications that have visually compelling user experiences, seamless communication across technology boundaries, the ability to support a wide range of business processes, and an easier way to manage your personal information online. Now the same great WinFX technology you know and love has a new name that identifies it for exactly what it is – the next version of Microsoft’s development framework. This change does not affect the release schedule of the .NET Framework 3.0 or the technologies included as a part of the package.
What is CTS (Common Type System)?
Common Type System Overview
Classification of Types
The common type system supports two general categories of types, each of which is further divided into subcategories:
· Value types
Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.
· Reference types
Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.
Managed Execution Process
Managed Execution Process
The managed execution process includes the following steps:
1. Choosing a compiler.
To obtain the benefits provided by the common language runtime, you must use one or more language compilers that target the runtime.
2. Compiling your code to Microsoft intermediate language (MSIL).
Compiling translates your source code into MSIL and generates the required metadata.
3. Compiling MSIL to native code.
At execution time, a just-in-time (JIT) compiler translates the MSIL into native code. During this compilation, code must pass a verification process that examines the MSIL and metadata to find out whether the code can be determined to be type safe.
4. Running code.
Common Language Runtime Overview
To enable the runtime to provide services to managed code, language compilers must emit metadata that describes the types, members, and references in your code. Metadata is stored with the code; every loadable common language runtime portable executable (PE) file contains metadata. The runtime uses metadata to locate and load classes, lay out instances in memory, resolve method invocations, generate native code, enforce security, and set run-time context boundaries.
The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks as well as some other common programming errors. If your code is managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET Framework application. Because language compilers supply their own types, such as primitive types, you might not always know (or need to know) whether your data is being managed.
The common language runtime makes it easy to design components and applications whose objects interact across languages. Objects written in different languages can communicate with each other, and their behaviors can be tightly integrated. For example, you can define a class and then use a different language to derive a class from your original class or call a method on the original class. You can also pass an instance of a class to a method of a class written in a different language. This cross-language integration is possible because language compilers and tools that target the runtime use a common type system defined by the runtime, and they follow the runtime's rules for defining new types, as well as for creating, using, persisting, and binding to types.
As part of their metadata, all managed components carry information about the components and resources they were built against. The runtime uses this information to ensure that your component or application has the specified versions of everything it needs, which makes your code less likely to break because of some unmet dependency. Registration information and state data are no longer stored in the registry where they can be difficult to establish and maintain. Rather, information about the types you define (and their dependencies) is stored with the code as metadata, making the tasks of component replication and removal much less complicated.
Language compilers and tools expose the runtime's functionality in ways that are intended to be useful and intuitive to developers. This means that some features of the runtime might be more noticeable in one environment than in another. How you experience the runtime depends on which language compilers or tools you use. For example, if you are a Visual Basic developer, you might notice that with the common language runtime, the Visual Basic language has more object-oriented features than before. Following are some benefits of the runtime:
· Performance improvements.
· The ability to easily use components developed in other languages.
· Extensible types provided by a class library.
· New language features such as inheritance, interfaces, and overloading for object-oriented programming; support for explicit free threading that allows creation of multithreaded, scalable applications; support for structured exception handling and custom attributes.
If you use Microsoft® Visual C++® .NET, you can write managed code using Visual C++, which provides the benefits of a managed execution environment as well as access to powerful capabilities and expressive data types that you are familiar with. Additional runtime features include:
· Cross-language integration, especially cross-language inheritance.
· Garbage collection, which manages object lifetime so that reference counting is unnecessary.
· Self-describing objects, which make using Interface Definition Language (IDL) unnecessary.
· The ability to compile once and run on any CPU and operating system that supports the runtime.
You can also write managed code using the C# language, which provides the following benefits:
· Complete object-oriented design.
· Very strong type safety.
· A good blend of Visual Basic simplicity and C++ power.
· Garbage collection.
· Syntax and keywords similar to C and C++.
· Use of delegates rather than function pointers for increased type safety and security. Function pointers are available through the use of the unsafe C# keyword and the /unsafe option of the C# compiler (Csc.exe) for unmanaged code and data.
XSL Languages
XSL Languages
It started with XSL and ended up with XSLT, XPath, and XSL-FO.
It Started with XSL
XSL stands for EXtensible Stylesheet Language.
The World Wide Web Consortium (W3C) started to develop XSL because there was a need for an XML-based Stylesheet Language.
CSS = HTML Style Sheets
HTML uses predefined tags and the meaning of the tags are well understood.
The <table> element in HTML defines a table - and a browser knows how to display it.
Adding styles to HTML elements is simple. Telling a browser to display an element in a special font or color, is easy with CSS.
XSL = XML Style Sheets
XML does not use predefined tags (we can use any tag-names we like), and the meaning of these tags are not well understood.
A XSL describes how the XML document should be displayed! XSL consists of three parts: XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XPath is a language for navigating in XML documents. Before you continue you should have a basic understanding of the following: XSLT is the most important part of XSL. XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element. With XSLT you can add/remove elements and attributes to or from the output file. You can also rearrange and sort elements, perform tests and make decisions about which elements to hide and display, and a lot more. A common way to describe the transformation process is to say that XSLT transforms an XML source-tree into an XML result-tree. XSLT uses XPath to find information in an XML document. XPath is used to navigate through elements and attributes in XML documents. In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document. Nearly all major browsers have support for XML and XSLT. As of version 1.0.2, Firefox has support for XML and XSLT (and CSS). Mozilla includes Expat for XML parsing and has support to display XML + CSS. Mozilla also has some support for Namespaces. Mozilla is available with an XSLT implementation. As of version 8, Netscape uses the Mozilla engine, and therefore it has the same XML / XSLT support as Mozilla. As of version 9, Opera has support for XML and XSLT (and CSS). Version 8 supports only XML + CSS. As of version 6, Internet Explorer supports XML, Namespaces, CSS, XSLT, and XPath. Version 5 is NOT compatible with the official W3C XSL Recommendation. Example study: How to transform XML into XHTML using XSLT. The details of this example will be explained in the next chapter. The root element that declares the document to be an XSL style sheet is Note: The correct way to declare an XSL style sheet according to the W3C XSLT Recommendation is: or: To get access to the XSLT elements, attributes and features we must declare the XSLT namespace at the top of the document. The xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace. If you use this namespace, you must also include the attribute version="1.0". We want to transform the following XML document ("cdcatalog.xml") into XHTML: Viewing XML Files in Firefox and Internet Explorer: Open the XML file (typically by clicking on a link) - The XML document will be displayed with color-coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure. To view the raw XML source (without the + and - signs), select "View Page Source" or "View Source" from the browser menu. Viewing XML Files in Netscape 6: Open the XML file, then right-click in XML file and select "View Page Source". The XML document will then be displayed with color-coded root and child elements. Viewing XML Files in Opera 7: Open the XML file, then right-click in XML file and select "Frame" / "View Source". The XML document will be displayed as plain text. Then you create an XSL Style Sheet ("cdcatalog.xsl") with a transformation template: Add the XSL style sheet reference to your XML document ("cdcatalog.xml"): If you have an XSLT compliant browser it will nicely transform your XML into XHTML. An XSL style sheet consists of one or more set of rules that are called templates. Each template contains rules to apply when a specified node is matched. The The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document). Ok, let's look at a simplified version of the XSL file from the previous chapter: Since an XSL style sheet is an XML document itself, it always begins with the XML declaration: . The next element, The The content inside the The last two lines define the end of the template and the end of the style sheet. The Note: The value of the select attribute is an XPath expression. An XPath expression works like navigating a file system; where a forward slash (/) selects subdirectories. The XSL Note: The value of the select attribute is an XPath expression. An XPath expression works like navigating a file system; where a forward slash (/) selects subdirectories To sort the output, simply add an Note: The select attribute indicates what XML element to sort on. To put a conditional if test against the content of the XML file, add an To add a conditional test, add the Note: The value of the required test attribute contains the expression to be evaluated. To insert a multiple conditional test against the XML file, add the The If we add a select attribute to the Look at the following XSL style sheet: element could mean an HTML table, a piece of furniture, or something else - and a browser does not know how to display it.
XSL - More Than a Style Sheet Language
What You Should Already Know
What is XSLT?
XSLT = XSL Transformations
XSLT Uses XPath
How Does it Work?
Mozilla Firefox
Mozilla
Netscape
Opera
Internet Explorer
Correct Style Sheet Declaration
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Start with a Raw XML Document
.
.
.
Create an XSL Style Sheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
Link the XSL Style Sheet to the XML Document
.
.
.
XSLT
The
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
.
.
The
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
The
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
Where to put the Sort Information
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
The
Syntax
...
...some output if the expression is true...
...
Where to Put the
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
The
Syntax
... some output ...
... some output ....
Where to put the Choose Condition
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title
Artist
The
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
My CD Collection
Title:
Artist: