Re: Inhaltstyp eines Strings



Hallo.

Der Hintergrund meiner Frage ist einfach: Ich möchte für verschiedene
geschickte Strings im Chat einen automatischen Formatter anwenden. Die
Typen sind normaler Wiki-Text, Java, XML, HTML oder allgemeine
Listing-Zeilen für verbleibendes, etwa für Property-Dateien. Daher
kommen auch nur Fragmente, wie im zweiten und vierten Beispiel. Daher
muss ich auch gar nicht vollständig erkennen, was das für ein Typ
ist, und es auch gar nicht validieren. Die Betonung der Funktion liegt
auf "guess" und nicht etwa auf "validate". Bei den String habe ich auch
keinen Content-/MIME-Type. Wenn die Erkennung daneben liegt, ist das
auch nicht tragisch: Dann wird alles als Listing ausgegeben.

Ich werde nun wohl mit einigen Heuristiken drangehen, was nicht so
schwierig ist. Einen Automaten brauche ich dafür nicht bauen. (Aber
vielleicht doch, wo ich doch meine Diplomprüfung in Compilerbau und
Formale Sprachen gemacht habe ;-)

Christian

C.Ullenboom@xxxxxxxxxxxxxx wrote:
Hallo.

Ich bin gerade auf der Suche nach einer Funktion, die sich einen String
anschaut, und den möglichen Inhaltstyp liefert, etwa

guessContent( "Hallo Welt" ) -> TEXT
guessContent( "<hallo>Welt</hallo>" ) -> XML
guessContent( "class A { int i }" ) -> JAVA
guessContent( "void foo() { bar(); }" ) -> JAVA
guessContent( "Hallo <b>Welt</b>!" ) -> HTML

Kennt ihr da eine Open-Source Bibliothek die so eine Funktion enthält?

Christian

/**
* @author Dipl.-Inf. Christian Ullenboom
* @email C.Ullenboom@xxxxxxxxxxxxxx
* @url http://java-tutor.com
* @seminar einführung aufbau jsp servlet swing jfc xml ejb j2ee j2me
* @tipp "Java ist auch eine Insel". ISBN 3-89842-747-1
*/

.



Relevant Pages

  • Re: Recommendations for a web application framework?
    ... Yet I still see this duality wherein there's a Java class representing the form. ... you can not eliminate this duality if you want to use HTML templates and insert a value into a specific position in the template. ... To be perhaps a little clearer, what JSF does is ensure that the correspondence between identifiers and names in Java code and HTML content is one-way. ... Java may have a verbose syntax, but it's still much better than XML, especially with a decent IDE. ...
    (comp.lang.java.programmer)
  • Re: Using Java to produce HTML like a php script
    ... >I am a university student using a program that requires updated xml ... > described is going to be in java if possible). ... If you're simply looking to generate HTML within a Java program, ... It is also possible to use something called XSL to convert XML documents to ...
    (comp.lang.java.programmer)
  • Re: Need help to generate critical report
    ... in an html report say report.html in a 4 columns in java. ... Format each XML element ...
    (comp.lang.java.programmer)
  • Re: clueless student trying to parse XML
    ... html is not always parseable by an xml parser. ... regarding html are less strict than xml, which means valid HTML is not ... Java book, and use online resources. ...
    (comp.lang.java.programmer)
  • Re: application communication in xml without webservices?
    ... Java tools that work well with services designed to use cross-platform data ... elements that fall into the intersection of the .NET, Java and XML Schema ... >- webservices remove some of the complexity out of communicating ... >> that standardize how you'll use HTTP so that others who follow in your ...
    (microsoft.public.dotnet.framework.aspnet.webservices)