Salve, sto facendo un progetto nel quale dovrei inserire delle informazioni prese da twitter all'interno della mia applicazione.
Premettendo che non sono assolutamente un esperto, ho pensato di utilizzare le API di twitter per poter analizzare i file xml di risposta e generare il file html che mi interessa con xslt.
Questa è la mia jsp che ottiene il file xml:
Questo è il file xsl per la lettura dell'xmlcodice:<%@ page contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:import url="https://api.twitter.com/1/users/show.xml?screen_name=fguarin13" charEncoding="UTF-8"/> <?xml-stylesheet type="text/xsl" href="tutto.xsl"?>
Per completezza vi pubblico anche la risposta xml di twitter:codice:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/"> <html> <head> <title> Info Utente </title> </head> <body> Name: <xsl:value-of select="name"/> Location: <xsl:value-of select="location"/> Description: <xsl:value-of select="description"/> Statuses Count: <xsl:value-of select="statuses_count"/> Followers count: <xsl:value-of select="followers_count"/> Link InfoTwitter !! </body> </html> </xsl:template> </xsl:stylesheet>
Il mio problema è: Non riesco ad inserire il mio file xsl <?xml-stylesheet type="text/xsl" href="tutto.xsl"?> nella jsp per ottenere la trasformazione in html che mi interessa.codice:<?xml version="1.0" encoding="UTF-8"?> <user> <id>181123681</id> <name>Fredy guarin</name> <screen_name>fguarin13</screen_name> <location>Milano</location> <profile_image_url>http://a0.twimg.com/profile_images/2...age_normal.jpg</profile_image_url> <profile_image_url_https>https://si0.twimg.com/profile_images...age_normal.jpg</profile_image_url_https> <url>http://www.fredyguarin.com</url> <description>Futbolista colombiano..equipos...huila,envigado,boca juniors,saint etienne,fc porto. actualmente inter de milan..selecciones colombia sub 17,20 y mayores...</description><protected>false</protected> <followers_count>194154</followers_count><profile_background_color>707E96</profile_background_color><profile_text_color>333333</profile_text_color><profile_link_color>0900FF</profile_link_color><profile_sidebar_fill_color>EFEFEF</profile_sidebar_fill_color><profile_sidebar_border_color>EEEEEE</profile_sidebar_border_color><friends_count>57</friends_count> <created_at>Sat Aug 21 10:12:06 +0000 2010</created_at><favourites_count>3</favourites_count> <utc_offset>3600</utc_offset> <time_zone>Rome</time_zone> <profile_background_image_url>http://a0.twimg.com/profile_backgrou...0564885626.jpg</profile_background_image_url><profile_background_image_url_https>https://si0.twimg.com/profile_backgr...0564885626.jpg</profile_background_image_url_https><profile_background_tile>true</profile_background_tile><profile_use_background_image>true</profile_use_background_image><geo_enabled>false</geo_enabled> <verified>true</verified> <statuses_count>1202</statuses_count> <lang>es</lang> <contributors_enabled>false</contributors_enabled> <is_translator>false</is_translator> <listed_count>1219</listed_count> <show_all_inline_media>false</show_all_inline_media> <default_profile>false</default_profile> <default_profile_image>false</default_profile_image> <following/> <follow_request_sent/> <notifications/> <status> <created_at>Tue Aug 07 06:51:05 +0000 2012</created_at> <id>232730567219761152</id> <text>RT @Fguaro: @DanielCalderonn @fguarin13. Esto pa ti daniii abrazoooo guaro aca compartiendo con dani en su cumple abrazos!!!! http://t.c ...</text> <source>Twitter for iPhone</source> <truncated>false</truncated> <in_reply_to_status_id/><in_reply_to_user_id/> <in_reply_to_screen_name/> <geo/> <coordinates/> <place/> <contributors/> <retweeted_status> <created_at>Tue Aug 07 05:24:05 +0000 2012</created_at> <id>232708668444004352</id> <text>@DanielCalderonn @fguarin13. Esto pa ti daniii abrazoooo guaro aca compartiendo con dani en su cumple abrazos!!!! http://t.co/RYdYVhkF</text> <source>Twitter for BlackBerry®</source> <truncated>false</truncated> <in_reply_to_status_id/><in_reply_to_user_id>57250212</in_reply_to_user_id><in_reply_to_screen_name>DanielCalderonn</in_reply_to_screen_name><possibly_sensitive>false</possibly_sensitive> <geo/> <coordinates/> <place/> <contributors/> <retweet_count>2</retweet_count> <favorited>false</favorited> <retweeted>false</retweeted> </retweeted_status> <retweet_count>2</retweet_count> <favorited>false</favorited> <retweeted>false</retweeted> </status> </user>
Se lo inserisco dopo <c:import> praticamente non me lo legge, se invece lo inserisco prima di <c:import> mi da errore di sintassi xml.
Chiedo scusa se non stato troppo chiaro, se c'è qualcosa che non avete capito chiedete pure.
Grazie mille!!!
Ps.: Spero sia la sezione giusta!!![]()

Rispondi quotando