Просто о XSLT

2009-Вер-11, П'ятниця 10:27
[personal profile] finesoul
Links:

www.xml.com/pub/a/2000/08/02/xslt/index.html
gazette.linux.ru.net/lg89/danguer.html
ru.wikipedia.org/wiki/XSLT
devpinoy.org/blogs/keithrull/archive/2008/03/31/how-to-use-the-xmldatasource-object-load-xml-data-to-a-gridview.aspx
www.w3schools.com/Xpath/xpath_functions.asp

Input XML:

Input XML:
<?xml version="1.0" encoding="utf-8"?>
<Ripcenter >
<Ripcentercall PublicationDate="2009-09-10T00:00:00">
<Publication Name="24t " Code="24t ">
<Source Name="backup">
<RunningPrint Code="24T ">
<PrintingPlace Zone="24arh " ZonePPI="24arh " PrintingPlaceCode="HBB " PrintingPlaceName="Hornslet Bogtrykkeri" PrintingPlaceCodeRip="B" />
</RunningPrint>
</Source>
</Publication>
</Ripcentercal>
</Ripcenter >


XSLT Template:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:template match="/">
<root>
<xsl:apply-templates />
</root>
</xsl:template>

<xsl:template match="//Ripcentercall/Publication/Source/RunningPrint/PrintingPlace">
<xsl:element name="row" >
<xsl:attribute name="PublicationDate">
<xsl:value-of select="../../../../@PublicationDate" />
</xsl:attribute>
<xsl:attribute name="Publication">
<xsl:value-of select="../../../@Name" />
</xsl:attribute>

<xsl:attribute name="Source">
<xsl:value-of select="../../@Name" />
</xsl:attribute>

<xsl:attribute name="RunningPrint">
<xsl:value-of select="../@Code" />
</xsl:attribute>

<xsl:attribute name="Zone">
<xsl:value-of select="./@Zone" />
</xsl:attribute>

....
</xsl:element>
</xsl:template>
</xsl:stylesheet>


Output XML:
<?xml version="1.0" encoding="utf-8"?><root>
<row PublicationDate="2009-09-10T00:00:00" Publication="24t " Source="backup" RunningPrint="24T " Zone="24arh " ZonePPI="24arh " PrintingPlaceCode="HBB " PrintingPlaceName="Hornslet Bogtrykkeri" PrintingPlaceCodeRip="B" />
...
</root>

 


If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Лютий 2022

Н П В С Ч П С
  12345
6789101112
13141516171819
202122232425 26
2728     

За стиль дякую

Створено з Dreamwidth Studios
Сторінка створена 2025-Чер-17, Вівторок 09:39