blob: 2e165ba30baf5d0aeb4f8c4bfdb07447ada843a9 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqEditorWhatIsMimePath
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqEditorWhatIsMimePath
:description: Apache NetBeans wiki DevFaqEditorWhatIsMimePath
:toc: left
:toc-title:
:syntax: true
=== What is MimePath?
Basically, `MimePath` is an ordered list of mime types.
The reason why we
have come up with the concept of `MimePath` is that we need to support embedded
languages. In the simple world where code is written only in one language
and stored in files dedicated for that language it is enough to know the
mime type of a file in order to know its language and to load appropriate
editor features. The world, however, is not simple anymore and the reality
requires us to deal with situations when one file contains a mixture of
several different languages. An example is a web applications development
when people write JSP files that contain snippets of code in JSP, HTML, an expression
language, Java, JavaScript and possibly some other languages. The whole JSP file
can be broken up into sections containing code in different languages and
user expects to get features like coloring and code completion that are
appropriate for the mime type of each section. This is called language embedding.
In order to be able to describe the exact 'type' of each embedded block of
text Netbeans use an ordered list of mime types that describe languages along the way from the top level language (i.e. the mime type of the file itself) to the embedded block.
So, for example a java scriplet in a JSP file can be identified
by the list of two mime types `text/x-jsp, text/x-java`. The list
can be encoded in one `String` using the forward slash character as
a separator and that's what `MimePath` is. In our example the
`MimePath` of java scriplet in a JSP file is `text/x-jsp/text/x-java`.
The embedding can go indefinitely deep and you can have `MimePath` like
`text/x-jsp/text/html/text/el` for an expression language used in an
HTML attribute inside a JSP file - `<a href="${myLink}">...</a>`.
Since `MimePath` is required when you want
link:DevFaqEditorWhatIsMimeLookup.asciidoc[MimeLookup] and since `MimeLookup` is the
way for pluging-in language specific editor features it is possible to
provide features tailored specifically for any type of language embedding.
If you want to know more about the contents of `MimeLookup` generally and
for compound and embedded mime types, read more in [[DevFaqEditorHowIsMimeLookupComposed| How is MimeLookup
composed?]].
---
Applies to: NetBeans 5.x, 6.x
Platforms: All
See also:
link:DevFaqEditorWhatIsMimeLookup.asciidoc[What is MimeLookup?],
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-mimelookup/org/netbeans/api/editor/mimelookup/MimePath.html[MimePath Javadoc],
link:http://www.netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-mimelookup/index.html[MimeLookup API]
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqEditorWhatIsMimePath[http://wiki.netbeans.org/DevFaqEditorWhatIsMimePath] ,
that was last modified by NetBeans user Vstejskal
on 2010-06-16T14:03:23Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.