Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_20230801
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
alx_20230801
Commits
42db4170
Commit
42db4170
authored
Aug 03, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Klient Dispatcher z XSLT po stronie klienta
parent
59970b7b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
2 deletions
+123
-2
.gitignore
OgloszeniaKlient/.gitignore
+2
-2
arkusz.xsl
OgloszeniaKlient/arkusz.xsl
+75
-0
Klient5_DispatcherXSLT.java
...oszenia/klient_niskopoziomowy/Klient5_DispatcherXSLT.java
+34
-0
Utils.java
...src/main/java/ogloszenia/klient_niskopoziomowy/Utils.java
+12
-0
No files found.
OgloszeniaKlient/.gitignore
View file @
42db4170
...
@@ -32,4 +32,5 @@ build/
...
@@ -32,4 +32,5 @@ build/
.vscode/
.vscode/
### Mac OS ###
### Mac OS ###
.DS_Store
.DS_Store
\ No newline at end of file
/wynik.html
OgloszeniaKlient/arkusz.xsl
0 → 100644
View file @
42db4170
<?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"
encoding=
"utf-8"
/>
<xsl:template
match=
"/"
>
<html>
<head>
<style
type=
"text/css"
>
<xsl:call-template
name=
"css"
/>
</style>
</head>
<body><xsl:apply-templates/></body>
</html>
</xsl:template>
<xsl:template
match=
"ogloszenie"
>
<div
class=
"ogloszenie"
>
<h2>
<xsl:apply-templates
select=
"marka"
/>
<xsl:text>
</xsl:text>
<xsl:apply-templates
select=
"model"
/>
<xsl:text>
</xsl:text>
<xsl:apply-templates
select=
"generacja"
/>
</h2>
<p>
Rocznik:
<b><xsl:value-of
select=
"rok-produkcji"
/></b></p>
<p><b><xsl:value-of
select=
"cena"
/></b></p>
<p
class=
"tytul"
><xsl:apply-templates
select=
"opis"
/></p>
<p>
Licznik:
<b><xsl:value-of
select=
"stan-licznika"
/></b></p>
<xsl:call-template
name=
"silnik"
/>
<xsl:apply-templates
select=
"sprzedawca"
/>
</div>
</xsl:template>
<xsl:template
name=
"silnik"
>
<div>
Silnik:
<b><xsl:value-of
select=
"pojemnosc"
/></b>
<xsl:text>
</xsl:text>
<b><xsl:value-of
select=
"moc"
/></b>
(
<xsl:value-of
select=
"paliwo"
/>
)
</div>
</xsl:template>
<xsl:template
match=
"sprzedawca"
>
<div>
<h3>
Sprzedawca
</h3>
<p><xsl:value-of
select=
"nazwa"
/></p>
<p><xsl:value-of
select=
"adres/ulica"
/></p>
<p><xsl:value-of
select=
"adres/kod-pocztowy"
/>
<xsl:text>
</xsl:text>
<xsl:value-of
select=
"adres/miasto"
/>
</p>
<p>
Kontakt:
<xsl:value-of
select=
"telefon"
/>
<xsl:text>
</xsl:text>
<xsl:value-of
select=
"email"
/></p>
</div>
</xsl:template>
<xsl:template
name=
"css"
>
<![CDATA[
body {
background-color: #FFFFDD;
}
.ogloszenie {
border: outset 4px #FF4488;
padding: 0.5em;
margin: 1em;
background-color: #EEFFFF;
}
]]>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
OgloszeniaKlient/src/main/java/ogloszenia/klient_niskopoziomowy/Klient5_DispatcherXSLT.java
0 → 100644
View file @
42db4170
package
ogloszenia
.
klient_niskopoziomowy
;
import
jakarta.xml.ws.Dispatch
;
import
jakarta.xml.ws.Service
;
import
ogloszenia.generated.OgloszeniaService
;
import
javax.xml.namespace.QName
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.stream.StreamSource
;
import
java.io.StringReader
;
public
class
Klient5_DispatcherXSLT
{
static
final
String
trescXML
=
"""
<o:readOne xmlns:o="
http:
//soap.ogloszenia/">
<
id
>
1
</
id
>
</
o:
readOne
>
""";
public static void main(String[] args) {
System.out.println("
Startujemy
...
");
OgloszeniaService service = new OgloszeniaService();
QName portName = OgloszeniaService.OgloszeniaPort;
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
System.out.println("
Mam
Dispatchera
" + dispatch);
Source src = new StreamSource(new StringReader(trescXML));
System.out.println("
Wysy
ł
am
zapytanie
");
Source result = dispatch.invoke(src);
System.out.println("
Mam
wynik:
" + result);
Utils utils = new Utils();
utils.xslt(result, "
arkusz
.
xsl
", "
wynik
.
html
");
System.out.println("
Gotowe
"
);
}
}
OgloszeniaKlient/src/main/java/ogloszenia/klient_niskopoziomowy/Utils.java
View file @
42db4170
...
@@ -2,6 +2,7 @@ package ogloszenia.klient_niskopoziomowy;
...
@@ -2,6 +2,7 @@ package ogloszenia.klient_niskopoziomowy;
import
javax.xml.transform.*
;
import
javax.xml.transform.*
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
public
class
Utils
{
public
class
Utils
{
private
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
private
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
...
@@ -16,4 +17,15 @@ public class Utils {
...
@@ -16,4 +17,15 @@ public class Utils {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
public
void
xslt
(
Source
src
,
String
arkusz
,
String
wyjscie
)
{
try
{
Transformer
transformer
=
tf
.
newTransformer
(
new
StreamSource
(
arkusz
));
transformer
.
setOutputProperty
(
OutputKeys
.
INDENT
,
"yes"
);
StreamResult
res
=
new
StreamResult
(
wyjscie
);
transformer
.
transform
(
src
,
res
);
}
catch
(
TransformerException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment