Hoewel ik veel XSL topics in /13 vond via de search, denk ik dat deze oplossing toch meer in /14 zal liggen, zeker omdat ik mijn XSL/XML via PHP parse aan de serverside.
Ik heb volgens mij al mijn namespaces goed gedeclareerd, maar toch krijg ik alsnog rare output. Mijn input ziet er als volgt uit:
input:
Vervolgens transformeer ik het met XSL:
stylesheet
Ik heb de default namespaces weggelaten, omdat dat nogal eens voor problemen zorgt in XSL. Op zich is mijn output dan nog goed, maar daarna doe ik nog een transformatie. Mijn output van hierboven is:
Output:
De stylesheet die ik vervolgens toepas hierop.
Stylesheet:
Hierna is mijn output simpelweg belabbert:
Output:
En dan bedoel ik m.n. de onnodige namespace declaraties overal. Is er een instelling wat ik moet veranderen in de parser? Of misschien een bug? Of moet ik het toch meer bij mijzelf zoeken? Ik heb via de search en Google veel pagina's gelezen, die met name focussen op de problemen met default-namespace, maar daar gaat het hier volgens mij niet om. Iemand ervaringen?
Ik heb volgens mij al mijn namespaces goed gedeclareerd, maar toch krijg ik alsnog rare output. Mijn input ziet er als volgt uit:
input:
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| <dataroot xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <mysql:source id="1"> <mysql:result xmlns:mysql="http://schema.domein.ext/mysql/" id="7"> <mysql:set> <quotesns:quoteId xmlns="http://schema.domein.ext/quotes/">1</quotesns:quoteId> <quotesext:quoteTitle xmlns="http://schema.domein.ext/quotesExtended/">Testartikel</quotesext:quoteTitle> </mysql:set> </mysql:result> </mysql:source> </dataroot> |
Vervolgens transformeer ik het met XSL:
stylesheet
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| <xsl:stylesheet version="1.0" xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" /> <xsl:template match="/"> <core:root> <xsl:apply-templates /> </core:root> </xsl:template> <xsl:template match="mysql:source"> <xsl:apply-templates /> </xsl:template> <xsl:template match="mysql:result"> <xsl:for-each select="mysql:set"> <xsl:copy-of select="*[1]" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> |
Ik heb de default namespaces weggelaten, omdat dat nogal eens voor problemen zorgt in XSL. Op zich is mijn output dan nog goed, maar daarna doe ik nog een transformatie. Mijn output van hierboven is:
Output:
XML:
1
2
3
4
| <?xml version="1.0" encoding="utf-8"?> <core:root xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <quotesns:quoteId xmlns="http://schema.domein.ext/quotes/">1</quotesns:quoteId> </core:root> |
De stylesheet die ik vervolgens toepas hierop.
Stylesheet:
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <xsl:stylesheet version="1.0" xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" /> <xsl:template match="/"> <core:root> <xsl:copy-of select="*[1]" /> </core:root> </xsl:template> </xsl:stylesheet> |
Hierna is mijn output simpelweg belabbert:
Output:
XML:
1
2
3
4
5
6
7
8
| <?xml version="1.0" encoding="utf-8"?> <core:root xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <core:buffer xmlns="http://schema.domein.ext/" xmlns:quotesns="http://schema.domein.ext/quotes/"> <core:root xmlns:core="http://schema.domein.ext/" xmlns:mysql="http://schema.domein.ext/mysql/" xmlns:quotesns="http://schema.domein.ext/quotes/" xmlns:quotesext="http://schema.domein.ext/quotesExtended/"> <quotesns:quoteId xmlns="http://schema.domein.ext/quotes/">1</quotesns:quoteId> </core:root> </core:buffer> </core:root> |
En dan bedoel ik m.n. de onnodige namespace declaraties overal. Is er een instelling wat ik moet veranderen in de parser? Of misschien een bug? Of moet ik het toch meer bij mijzelf zoeken? Ik heb via de search en Google veel pagina's gelezen, die met name focussen op de problemen met default-namespace, maar daar gaat het hier volgens mij niet om. Iemand ervaringen?
[ Voor 4% gewijzigd door r0bert op 02-08-2008 17:03 ]