Attribute (computing)

Last updated
In object-oriented programming, classes can contain attributes and methods CPT-OOP-objects and classes - attmeth.svg
In object-oriented programming, classes can contain attributes and methods
An attribute in a relational database can be represented as a column or field Relational database terms.svg
An attribute in a relational database can be represented as a column or field

In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such. For clarity, attributes should more correctly be considered metadata. An attribute is frequently and generally a property of a property. However, in actual usage, the term attribute can and is often treated as equivalent to a property depending on the technology being discussed. An attribute of an object usually consists of a name and a value. For an element these can be a type and class name, while for a file these can be a name and an extension, respectively.

Contents

Rules and typing

Picture file formats (for example JPEG, PNG and BMP) are not decoded using the same operations (however similar the images look these are all graphics data formats). Similarly, a programming language does not use the same operations to evaluate a floating point typed number and typed long integers.

For example, in computer graphics, line objects can have attributes such as thickness (with real values), color (with descriptive values such as brown or green or values defined in a certain color model, such as RGB), dashing attributes, etc. A circle object can be defined in similar attributes plus an origin and radius. In reference to computer systems, attributes are defined particularly for read or write attributes for specific read or write.

Attribute usage

If the element in question could be considered a property (CUSTOMER_NAME) of another entity (let's say CUSTOMER), the element can have zero or more attributes (properties) of its own (CUSTOMER_NAME is of TYPE = "KINDOFTEXT").

C#

In the C# programming language, attributes are metadata attached to a field or a block of code like assemblies, members and types, and are equivalent to annotations in Java. Attributes are accessible to both the compiler and programmatically through reflection. In contrast, properties, in C# terminology, are members of a class which syntactically are used like instance (or class) variables, but are implemented as a pair of getter/setter functions. (In the absence of a setter, properties are read-only.)

Users of the language see many examples where attributes are used to address cross-cutting concerns and other mechanistic or platform uses. This creates the false impression that this is their sole intended purpose.

Their specific use as metadata is left to the developer and can cover a wide range of types of information about any given application, classes and members that is not instance-specific. The decision to expose any given attribute as a property is also left to the developer as is the decision to use them as part of a larger application framework.

Attributes are implemented as classes that are derived from System.Attribute. They are often used by the CLR services, like COM interoperability, remoting, serialisation and can be queried at runtime.

The example shows how attributes are defined in C#:

[Obsolete("Use class C1 instead", IsError = true)]// causes compiler message sayingpublicclassC{...}// that C is obsoletepublicclassObsoleteAttribute:Attribute{// class name ends with "Attribute"publicstringMessage{get;}// but can be used as "Obsolete"publicboolIsError{get;set;}publicObsoleteAttribute(){...}publicObsoleteAttribute(stringmsg){...}publicObsoleteAttribute(stringmsg,boolerror){...}}[Obsolete][Obsolete("This is obsolete")][Obsolete("This is obsolete", false)][Obsolete("This is obsolete", IsError = false)]

Positional parameters like first parameter of type string above are parameters of the attribute's constructor. Name parameters like the Boolean parameter in the example are a property of the attribute and should be a constant value. [1]

Attributes should be contrasted against XML documentation that also defines metadata, but is not included in the compiled assembly and therefore cannot be accessed programmatically.

HTML & JavaScript

Display the checked attribute and property of a checkbox as it changes.

<!doctype html><htmllang="en"><head><body><inputname="food"type="meal"id="meal"><metacharset="utf-8"><title>attr demo</title><style>p{border;1pxsolidblack;font-family;arial,sans-serif;text-aligncenter;}b{color:blue;}</style><scriptsrc="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><inputid="check1"type="checkbox"checked="checked"><labelfor="check1">Check me</label><p></p><script>$("input").change(function(){var$input=$(this);$("p").html(".attr( 'checked' ): <b>"+$input.attr("checked")+"</b><br>"+".prop( 'checked' ): <b>"+$input.prop("checked")+"</b><br>"+".is( ':checked' ): <b>"+$input.is(":checked")+"</b>");}).change();</script></body></html>

before click

.attr('checked'):checked.prop('checked'):false.is(':checked'):false

after click

.attr('checked'):checked.prop('checked'):true.is(':checked'):true

Multi-valued databases

On many post-relational or multi-valued databases systems, relative to SQL, tables are files, rows are items, and columns are attributes. Both in the database and code, attribute is synonymous with property and variable although attributes can be further defined to contain values and subvalues.

The first of these databases was the Pick operating system. Two current platforms include Rocket U2's Universe and InterSystems' Caché.

XML

In XML, an attribute is a markup construct consisting of a name/value pair that exists within a start-tag or empty-element tag. Markup languages, such as HTML and XML, use attributes to describe data and the formatting of data.

A good example is the process of XML assigning values to properties (elements). Note that the element's value is found before the (separate) end tag, not in the element itself. The element itself may have a number of attributes set (NAME = "IAMAPROPERTY").

If the element in question could be considered a property (CUSTOMER_NAME) of another entity (let's say CUSTOMER), the element can have zero or more attributes (properties) of its own (CUSTOMER_NAME is of TYPE = "KINDOFTEXT").

See also

Related Research Articles

A document type definition (DTD) is a specification file that contains set of markup declarations that define a document type for an SGML-family markup language. The DTD specification file can be used to validate documents.

<span class="mw-page-title-main">HTML</span> HyperText Markup Language

The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It defines the meaning and structure of web content. It is often assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript.

<span class="mw-page-title-main">XML</span> Markup language by the W3C for encoding of data

Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The World Wide Web Consortium's XML 1.0 Specification of 1998 and several other related specifications—all of them free open standards—define XML.

XSD, a recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. It can be used by programmers to verify each piece of item content in a document, to assure it adheres to the description of the element it is placed in.

An HTML element is a type of HTML document component, one of several types of HTML nodes. The first used version of HTML was written by Tim Berners-Lee in 1993 and there have since been many versions of HTML. The current de facto standard is governed by the industry group WHATWG and is known as the HTML Living Standard.

<span class="mw-page-title-main">Node (computer science)</span> Basic unit of a data structure

A node is a basic unit of a data structure, such as a linked list or tree data structure. Nodes contain data and also may link to other nodes. Links between nodes are often implemented by pointers.

<span class="mw-page-title-main">XBRL</span> Exchange format for business information

XBRL is a freely available and global framework for exchanging business information. XBRL allows the expression of semantic meaning commonly required in business reporting. The standard was originally based on XML, but now additionally supports reports in JSON and CSV formats, as well as the original XML-based syntax. XBRL is also increasingly used in its Inline XBRL variant, which embeds XBRL tags into an HTML document. One common use of XBRL is the exchange of financial information, such as in a company's annual financial report. The XBRL standard is developed and published by XBRL International, Inc. (XII).

The Darwin Information Typing Architecture (DITA) specification defines a set of document types for authoring and organizing topic-oriented information, as well as a set of mechanisms for combining, extending, and constraining document types. It is an open standard that is defined and maintained by the OASIS DITA Technical Committee.

Metadata, in the Common Language Infrastructure (CLI), refers to certain data structures embedded within the Common Intermediate Language (CIL) code that describes the high-level structure of the code. Metadata describes all classes and class members that are defined in the assembly, and the classes and class members that the current assembly will call from another assembly. The metadata for a method contains the complete description of the method, including the class, the return type and all of the method parameters.

A representation term is a word, or a combination of words, that semantically represent the data type of a data element. A representation term is commonly referred to as a class word by those familiar with data dictionaries. ISO/IEC 11179-5:2005 defines representation term as a designation of an instance of a representation class As used in ISO/IEC 11179, the representation term is that part of a data element name that provides a semantic pointer to the underlying data type. A Representation class is a class of representations. This representation class provides a way to classify or group data elements.

This article describes the technical specifications of the OpenDocument office document standard, as developed by the OASIS industry consortium. A variety of organizations developed the standard publicly and make it publicly accessible, meaning it can be implemented by anyone without restriction. The OpenDocument format aims to provide an open alternative to proprietary document formats.

In the Java computer programming language, an annotation is a form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and Java packages may be annotated. Like Javadoc tags, Java annotations can be read from source files. Unlike Javadoc tags, Java annotations can also be embedded in and read from Java class files generated by the Java compiler. This allows annotations to be retained by the Java virtual machine at run-time and read via reflection. It is possible to create meta-annotations out of the existing ones in Java.

RDFa or Resource Description Framework in Attributes is a W3C Recommendation that adds a set of attribute-level extensions to HTML, XHTML and various XML-based document types for embedding rich metadata within Web documents. The Resource Description Framework (RDF) data-model mapping enables its use for embedding RDF subject-predicate-object expressions within XHTML documents. It also enables the extraction of RDF model triples by compliant user agents.

An entity–attribute–value model (EAV) is a data model optimized for the space-efficient storage of sparse—or ad-hoc—property or data values, intended for situations where runtime usage patterns are arbitrary, subject to user variation, or otherwise unforeseeable using a fixed design. The use-case targets applications which offer a large or rich system of defined property types, which are in turn appropriate to a wide set of entities, but where typically only a small, specific selection of these are instantiated for a given entity. Therefore, this type of data model relates to the mathematical notion of a sparse matrix.

The Prototype JavaScript Framework is a JavaScript framework created by Sam Stephenson in February 2005 as part of Ajax support in Ruby on Rails. It is implemented as a single file of JavaScript code, usually named prototype.js. Prototype is distributed standalone, but also as part of larger projects, such as Ruby on Rails, script.aculo.us and Rico. As of March 2021, according to w3techs, Prototype is used by 0.6% of all websites.

jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax. It is free, open-source software using the permissive MIT License. As of August 2022, jQuery is used by 77% of the 10 million most popular websites. Web analysis indicates that it is the most widely deployed JavaScript library by a large margin, having at least 3 to 4 times more usage than any other JavaScript library.

This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.

In computing, Facelets is an open-source Web template system under the Apache license and the default view handler technology for Jakarta Server Faces. The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on building the JSF component tree, reflecting the view for a JSF application.

The Office Open XML file formats are a set of file formats that can be used to represent electronic office documents. There are formats for word processing documents, spreadsheets and presentations as well as specific formats for material such as mathematical formulae, graphics, bibliographies etc.

HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of a HTML element type. An attribute either modifies the default functionality of an element type or provides functionality to certain element types unable to function correctly without them. In HTML syntax, an attribute is added to a HTML start tag.

References

  1. Mössenböck, Hanspeter (2002-03-25). "Advanced C#: Variable Number of Parameters" (PDF). Institut für Systemsoftware, Johannes Kepler Universität Linz, Fachbereich Informatik. p. 44. Retrieved 2011-08-08.