diff --git a/pom.xml b/pom.xml index 59c500a03a45d01704b5ca511e856a710824364e..3bdd527417631f7435f1796cd252cdc094cf2a21 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,10 @@ <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-kotlin</artifactId> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt index 74018cd1127b9b8f5a01fcd3b1c83c48c5a38887..1ae2e7b11f4484631bbdb02307aaec482838d2f5 100644 --- a/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt @@ -1,9 +1,16 @@ package com.s3ai.corporate_app2.controllers +import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.s3ai.corporate_app2.CinemaServices -import org.springframework.ui.Model +import org.springframework.util.ResourceUtils +import java.io.StringReader +import java.io.StringWriter import java.util.* import javax.servlet.http.HttpServletResponse +import javax.xml.transform.TransformerFactory +import javax.xml.transform.stream.StreamResult +import javax.xml.transform.stream.StreamSource + fun <T> deleteInstance(id: String, instanceName: String, jpaService: CinemaServices<T>, response: HttpServletResponse): String? { var responseString: String? = null @@ -20,4 +27,30 @@ fun <T> deleteInstance(id: String, instanceName: String, jpaService: CinemaServi responseString = e.localizedMessage } return responseString -} \ No newline at end of file +} + +fun <T> getInstance(id: UUID, jpaService: CinemaServices<T>, response: HttpServletResponse): T? { + val item = jpaService.findById(id) + if (null != item) return item + else response.status = HttpServletResponse.SC_NOT_FOUND + return null +} + +fun XMLTransform(item: Any, resource_name: String): String { + val xmlMapper = XmlMapper() + val xslt = StreamSource(ResourceUtils.getFile("classpath:xslt/$resource_name")) + val xml = StreamSource(StringReader(xmlMapper.writeValueAsString(item))) + val transformer = TransformerFactory.newInstance().newTransformer(xslt) + val sw = StringWriter() + transformer.transform(xml, StreamResult(sw)) + return sw.toString() +} + +fun <T> getXSLTransformedInstance(id: UUID, jpaService: CinemaServices<T>, resource_name: String, response: HttpServletResponse): String { + val item = jpaService.findById(id) + if (null == item) response.status = HttpServletResponse.SC_NOT_FOUND + else { + return XMLTransform(item, resource_name) + } + return "" +} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/CinemasJsonController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/CinemasJsonController.kt new file mode 100644 index 0000000000000000000000000000000000000000..033ea39a4dc654989dd0656349f037526162a3c1 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/CinemasJsonController.kt @@ -0,0 +1,31 @@ +package com.s3ai.corporate_app2.controllers.rest.json + +import com.s3ai.corporate_app2.Cinema +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/json/cinemas/") +class CinemasJsonController { + @Autowired + lateinit var cinemaService: CinemaService + + @GetMapping("/all", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getCinemas(response: HttpServletResponse): MutableList<Cinema> { + return cinemaService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getCinema(@PathVariable id: UUID, response: HttpServletResponse): Cinema? { + return getInstance(id, cinemaService, response) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/TicketsJsonController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/TicketsJsonController.kt new file mode 100644 index 0000000000000000000000000000000000000000..12e7eec1804795371bfe8cd0a22c2b943da871c9 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/TicketsJsonController.kt @@ -0,0 +1,31 @@ +package com.s3ai.corporate_app2.controllers.rest.json + +import com.s3ai.corporate_app2.Ticket +import com.s3ai.corporate_app2.TicketService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/json/tickets/") +class TicketsJsonController { + @Autowired + lateinit var ticketService: TicketService + + @GetMapping("/all", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getTickets(response: HttpServletResponse): MutableList<Ticket> { + return ticketService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getTicket(@PathVariable id: UUID, response: HttpServletResponse): Ticket? { + return getInstance(id, ticketService, response) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/UsersJsonController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/UsersJsonController.kt new file mode 100644 index 0000000000000000000000000000000000000000..72cb67d4e148604740d5f3d14a4526ca545bf35f --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/json/UsersJsonController.kt @@ -0,0 +1,31 @@ +package com.s3ai.corporate_app2.controllers.rest.json + +import com.s3ai.corporate_app2.User +import com.s3ai.corporate_app2.UserService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/json/users/") +class UsersJsonController { + @Autowired + lateinit var userService: UserService + + @GetMapping("/all", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getUsers(response: HttpServletResponse): MutableList<User> { + return userService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getUser(@PathVariable id: UUID, response: HttpServletResponse): User? { + return getInstance(id, userService, response) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/CinemasXmlController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/CinemasXmlController.kt new file mode 100644 index 0000000000000000000000000000000000000000..c5664290c659e70456f6097df0a31c91e7bef535 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/CinemasXmlController.kt @@ -0,0 +1,31 @@ +package com.s3ai.corporate_app2.controllers.rest.xml + +import com.s3ai.corporate_app2.Cinema +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xml/cinemas/") +class CinemasXmlController { + @Autowired + lateinit var cinemaService: CinemaService + + @GetMapping("/all", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getCinemas(response: HttpServletResponse): MutableList<Cinema> { + return cinemaService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getCinema(@PathVariable id: UUID, response: HttpServletResponse): Cinema? { + return getInstance(id, cinemaService, response) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/TicketsXmlController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/TicketsXmlController.kt new file mode 100644 index 0000000000000000000000000000000000000000..ddd5b7910103e9e6c005a47f3d4551ea08fd8c7f --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/TicketsXmlController.kt @@ -0,0 +1,30 @@ +package com.s3ai.corporate_app2.controllers.rest.xml + +import com.s3ai.corporate_app2.Ticket +import com.s3ai.corporate_app2.TicketService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xml/tickets/") +class TicketsXmlController { + @Autowired + lateinit var ticketService: TicketService + + @GetMapping("/all", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getTickets(response: HttpServletResponse): MutableList<Ticket> { + return ticketService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getTicket(@PathVariable id: UUID, response: HttpServletResponse): Ticket? { + return getInstance(id, ticketService, response) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/UsersXmlController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/UsersXmlController.kt new file mode 100644 index 0000000000000000000000000000000000000000..4de521bf1ec6d54200eb2d943ab6d8b1082d3bc9 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xml/UsersXmlController.kt @@ -0,0 +1,30 @@ +package com.s3ai.corporate_app2.controllers.rest.xml + +import com.s3ai.corporate_app2.User +import com.s3ai.corporate_app2.UserService +import com.s3ai.corporate_app2.controllers.getInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xml/users/") +class UsersXmlController { + @Autowired + lateinit var userService: UserService + + @GetMapping("/all", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getUsers(response: HttpServletResponse): MutableList<User> { + return userService.findAll() + } + + @GetMapping("/item/{id}", produces = [MediaType.APPLICATION_XML_VALUE]) + fun getUser(@PathVariable id: UUID, response: HttpServletResponse): User? { + return getInstance(id, userService, response) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/CinemasXsltController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/CinemasXsltController.kt new file mode 100644 index 0000000000000000000000000000000000000000..498cd0a4c3c3e7330ee2e3eb1e19bbbf61a68898 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/CinemasXsltController.kt @@ -0,0 +1,33 @@ +package com.s3ai.corporate_app2.controllers.rest.xslt + +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.controllers.XMLTransform +import com.s3ai.corporate_app2.controllers.getXSLTransformedInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xslt/cinemas/") +class CinemasXsltController { + @Autowired + lateinit var cinemaService: CinemaService + + val xsltResourceName: String = "cinema-process.xslt" + + @GetMapping("/all", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinemas(response: HttpServletResponse): String { + return XMLTransform(cinemaService.findAll(), xsltResourceName) + } + + + @GetMapping("/item/{id}", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinema(@PathVariable id: UUID, response: HttpServletResponse): String? { + return getXSLTransformedInstance(id, cinemaService, xsltResourceName, response) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/TicketsXsltController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/TicketsXsltController.kt new file mode 100644 index 0000000000000000000000000000000000000000..896eca4cfa2307bd44cbbd5248e43eb0414dfc77 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/TicketsXsltController.kt @@ -0,0 +1,33 @@ +package com.s3ai.corporate_app2.controllers.rest.xslt + +import com.s3ai.corporate_app2.TicketService +import com.s3ai.corporate_app2.controllers.XMLTransform +import com.s3ai.corporate_app2.controllers.getXSLTransformedInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xslt/tickets/") +class TicketsXsltController { + @Autowired + lateinit var ticketService: TicketService + + val xsltResourceName: String = "ticket-process.xslt" + + @GetMapping("/all", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinemas(response: HttpServletResponse): String { + return XMLTransform(ticketService.findAll(), xsltResourceName) + } + + + @GetMapping("/item/{id}", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinema(@PathVariable id: UUID, response: HttpServletResponse): String? { + return getXSLTransformedInstance(id, ticketService, xsltResourceName, response) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/UsersXsltController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/UsersXsltController.kt new file mode 100644 index 0000000000000000000000000000000000000000..f07ee83001d9f34d50759b285b85bfaac6f733d5 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/xslt/UsersXsltController.kt @@ -0,0 +1,33 @@ +package com.s3ai.corporate_app2.controllers.rest.xslt + +import com.s3ai.corporate_app2.UserService +import com.s3ai.corporate_app2.controllers.XMLTransform +import com.s3ai.corporate_app2.controllers.getXSLTransformedInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/xslt/users/") +class UsersXsltController { + @Autowired + lateinit var userService: UserService + + val xsltResourceName: String = "user-process.xslt" + + @GetMapping("/all", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinemas(response: HttpServletResponse): String { + return XMLTransform(userService.findAll(), xsltResourceName) + } + + + @GetMapping("/item/{id}", produces = [MediaType.TEXT_HTML_VALUE]) + fun getCinema(@PathVariable id: UUID, response: HttpServletResponse): String? { + return getXSLTransformedInstance(id, userService, xsltResourceName, response) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/entities.kt b/src/main/kotlin/com/s3ai/corporate_app2/entities.kt index c84b767c4d32aa4b2f9c0b95d054c0d39f6a076f..28ceb6de27ba2516cba897c2e0c56c4c03ca1897 100644 --- a/src/main/kotlin/com/s3ai/corporate_app2/entities.kt +++ b/src/main/kotlin/com/s3ai/corporate_app2/entities.kt @@ -1,21 +1,30 @@ package com.s3ai.corporate_app2 +import com.fasterxml.jackson.annotation.JsonAutoDetect +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement import org.hibernate.annotations.OnDelete import org.hibernate.annotations.OnDeleteAction import java.util.* import javax.persistence.* +import javax.xml.bind.annotation.XmlRootElement @Entity @Table(name = "cinema") +@XmlRootElement(name = "Cinema") +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) class Cinema { @Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) var id: UUID? = null + @Column(name = "name") var name: String? = null + @Column(name = "seats_count") var seatsCount: Int? = null + @Column(name = "location") var location: String? = null @@ -27,6 +36,8 @@ class Cinema { @Entity @Table(name = "cinema_user") +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) +@XmlRootElement(name = "User") class User { @Id @Column(name = "ID") @@ -44,6 +55,7 @@ class User { @Entity @Table(name = "ticket") +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) class Ticket { @Id @Column(name = "ID") diff --git a/src/main/resources/xslt/cinema-process.xslt b/src/main/resources/xslt/cinema-process.xslt new file mode 100644 index 0000000000000000000000000000000000000000..8af051d7a541d0a002414305f2be108b4da1b5a3 --- /dev/null +++ b/src/main/resources/xslt/cinema-process.xslt @@ -0,0 +1,59 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + <xsl:template match="/ArrayList"> + <table> + <tr> + <th class="col">UUID</th> + <th class="col">Name</th> + <th class="col">Seats count</th> + <th class="col">Location</th> + </tr> + <xsl:apply-templates/> + </table> + </xsl:template> + + <xsl:template match="item"> + <tr> + <xsl:variable name="uuid" select="string(id)"/> + <td> + <a href="/api/xslt/cinemas/item/{$uuid}"> + <xsl:value-of select="string(id)"/> + </a> + </td> + <td> + <xsl:value-of select="string(name)"/> + </td> + <td> + <xsl:value-of select="string(seatsCount)"/> + </td> + <td> + <xsl:value-of select="string(location)"/> + </td> + </tr> + </xsl:template> + + <xsl:template match="Cinema"> + <div> + <a href="/api/xslt/cinemas/all">Go back to list</a> + </div> + <ul> + <li> + UUID: + <xsl:value-of select="string(id)"/> + </li> + <li> + Name: + <xsl:value-of select="string(name)"/> + </li> + <li> + Seats count: + <xsl:value-of select="string(seatsCount)"/> + </li> + <li> + Location: + <xsl:value-of select="string(location)"/> + </li> + </ul> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/src/main/resources/xslt/ticket-process.xslt b/src/main/resources/xslt/ticket-process.xslt new file mode 100644 index 0000000000000000000000000000000000000000..6ad132894ca8e9a43e1f894be507f8d91c4120fd --- /dev/null +++ b/src/main/resources/xslt/ticket-process.xslt @@ -0,0 +1,108 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + <xsl:template match="/ArrayList"> + <table> + <tr> + <th class="col">UUID</th> + <th class="col">Name</th> + <th class="col">Cinema id</th> + <th class="col">User id</th> + </tr> + <xsl:apply-templates/> + </table> + </xsl:template> + + <xsl:template match="item"> + <tr> + <xsl:variable name="uuid" select="string(id)"/> + <td> + <a href="/api/xslt/tickets/item/{$uuid}"> + <xsl:value-of select="string(id)"/> + </a> + </td> + <td> + <xsl:value-of select="string(movie)"/> + </td> + <xsl:variable name="cinema_id" select="string(cinema/id)"/> + <td> + <a href="/api/xslt/cinemas/item/{$cinema_id}"> + <xsl:value-of select="string(cinema/id)"/> + </a> + </td> + <xsl:variable name="user_id" select="string(user/id)"/> + <td> + <a href="/api/xslt/users/item/{$user_id}"> + <xsl:value-of select="string(user/id)"/> + </a> + </td> + + </tr> + </xsl:template> + + <xsl:template match="Ticket"> + <div> + <a href="/api/xslt/tickets/all">Go back to list</a> + </div> + <ul> + <li> + UUID: + <xsl:value-of select="string(id)"/> + </li> + <li> + Movie: + <xsl:value-of select="string(movie)"/> + </li> + <li> + <xsl:apply-templates select="cinema"/> + </li> + <li> + <xsl:apply-templates select="user"/> + </li> + + </ul> + </xsl:template> + + <xsl:template match="cinema"> + <p>Cinema:</p> + <ul> + <xsl:variable name="uuid" select="string(id)"/> + <li> + ID: + <a href="/api/xslt/cinemas/item/{$uuid}"> + <xsl:value-of select="string(id)"/> + </a> + </li> + <li> + Name: + <xsl:value-of select="string(name)"/> + </li> + <li> + Seats count: + <xsl:value-of select="string(seatsCount)"/> + </li> + <li> + Location: + <xsl:value-of select="string(location)"/> + </li> + </ul> + </xsl:template> + + <xsl:template match="user"> + <p>User:</p> + <ul> + <xsl:variable name="uuid" select="string(id)"/> + <li> + ID: + <a href="/api/xslt/users/item/{$uuid}"> + <xsl:value-of select="string(id)"/> + </a> + </li> + <li> + Name: <xsl:value-of select="string(name)"/> + </li> + <li> + Age: <xsl:value-of select="string(age)"/> + </li> + </ul> + </xsl:template> +</xsl:stylesheet> \ No newline at end of file diff --git a/src/main/resources/xslt/user-process.xslt b/src/main/resources/xslt/user-process.xslt new file mode 100644 index 0000000000000000000000000000000000000000..3834aa0831b581efd3374f66ec029838b28e2034 --- /dev/null +++ b/src/main/resources/xslt/user-process.xslt @@ -0,0 +1,51 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + <xsl:template match="/ArrayList"> + <table> + <tr> + <th class="col">UUID</th> + <th class="col">Name</th> + <th class="col">Age</th> + </tr> + <xsl:apply-templates/> + </table> + </xsl:template> + + <xsl:template match="item"> + <tr> + <xsl:variable name="uuid" select="string(id)"/> + <td> + <a href="/api/xslt/users/item/{$uuid}"> + <xsl:value-of select="string(id)"/> + </a> + </td> + <td> + <xsl:value-of select="string(name)"/> + </td> + <td> + <xsl:value-of select="string(age)"/> + </td> + </tr> + </xsl:template> + + <xsl:template match="User"> + <div> + <a href="/api/xslt/users/all">Go back to list</a> + </div> + <ul> + <li> + UUID: + <xsl:value-of select="string(id)"/> + </li> + <li> + Name: + <xsl:value-of select="string(name)"/> + </li> + <li> + Age: + <xsl:value-of select="string(age)"/> + </li> + </ul> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file