Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [XSL] non estrae valori da XML

    ho un foglio di stile che dovrebbe estrarre dei valori da un file XML di origine e riscriverli in un nuovo schema XML.
    Il problema è che lo schema viene scritto ma non vengono riportati i valori che intendo visualizzare.

    XML in input
    codice:
    <?xml version='1.0' encoding='ISO-8859-1' ?>
    <?xml-stylesheet type="text/xsl" href="t_contourshape.xsl"?>
    <Mpeg7><DescriptionUnit><Descriptor><Region><RegionNumber>255</RegionNumber>
    <GlobalCurvature>7  3 </GlobalCurvature>
    <PrototypeCurvature>1  3 </PrototypeCurvature>
    <HighestPeakY>15</HighestPeakY>
    <Peak peakX = "58" peakY = "5"/>
    <Peak peakX = "5" peakY = "7"/>
    <Peak peakX = "59" peakY = "1"/>
    <Peak peakX = "61" peakY = "6"/>
    <Peak peakX = "4" peakY = "6"/>
    <Peak peakX = "2" peakY = "6"/>
    <Peak peakX = "1" peakY = "7"/>
    </Region>
    </Descriptor>
    </DescriptionUnit>
    </Mpeg7>
    foglio di stile XSL
    codice:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="xml" encoding="utf-8"/>
    	<xsl:param name="instance" select="anonymous"/>
    	<xsl:template match="/" xmlns:tst="urn:mpeg:mpeg7:schema:2001" xml:base="http://www.acemedia.org/fact-statements/PROTOTYPES#"
    										xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    										xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema"
    										xmlns:vdo="http://www.acemedia.org/ontologies/VDO#"
    										xmlns:vdoext="http://www.acemedia.org/ontologies/VDO-EXT#">
    		<vdo:ContourShapeDescriptor rdf:about="{$instance}">
    			<xsl:variable name="gcevar" select="tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:GlobalCurvature"/>
    			<xsl:variable name="gcevar1" select="substring-before($gcevar,' ')"/>
    			<vdo:globalCurvatureCircularity>
    				<xsl:value-of select="$gcevar1"/>
    			</vdo:globalCurvatureCircularity>
    			<xsl:variable name="gcevar2" select="substring-before(substring-after($gcevar,'  '),' ')"/>
    			<vdo:globalCurvatureEccentricity>
    				<xsl:value-of select="$gcevar2"/>
    			</vdo:globalCurvatureEccentricity>
    			<xsl:variable name="pccvar" select="tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:PrototypeCurvature"/>
    			<xsl:variable name="pccvar1" select="substring-before($pccvar,' ')"/>
    			<vdo:prototypeCurvatureCircularity>
    				<xsl:value-of select="$pccvar1"/>
    			</vdo:prototypeCurvatureCircularity>
    			<xsl:variable name="pccvar2" select="substring-before(substring-after($pccvar,'  '),' ')"/>
    			<vdo:prototypeCurvatureEccentricity>
    				<xsl:value-of select="$pccvar2"/>
    			</vdo:prototypeCurvatureEccentricity>
    			<vdo:highestPeakY>
    				<xsl:value-of select="tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:HighestPeakY"/>
    			</vdo:highestPeakY>
    			<xsl:for-each select="tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:Peak">
    				<vdo:peakX>
    					<xsl:value-of select="./@peakX"/>
    				</vdo:peakX>
    			</xsl:for-each>
    			<xsl:for-each select="tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:Peak">
    				<vdo:peakY>
    					<xsl:value-of select="./@peakY"/>
    				</vdo:peakY>
    			</xsl:for-each>
    			<vdo:numberOfPeaks>
    				<xsl:value-of select="count(tst:Mpeg7/tst:DescriptionUnit/tst:Descriptor/tst:Region/tst:Peak)"/>
    			</vdo:numberOfPeaks>
    		</vdo:ContourShapeDescriptor>
    	</xsl:template>
    </xsl:stylesheet>
    XML in output. da notare i tag praticamente vuoti
    codice:
    <?xml version="1.0" encoding="utf-8"?>
    <vdo:ContourShapeDescriptor 
    	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema" 
    	xmlns:tst="urn:mpeg:mpeg7:schema:2001" 
    	xmlns:vdo="http://www.acemedia.org/ontologies/VDO#" 
    	xmlns:vdoext="http://www.acemedia.org/ontologies/VDO-EXT#" rdf:about="">
    <vdo:globalCurvatureCircularity></vdo:globalCurvatureCircularity>
    <vdo:globalCurvatureEccentricity></vdo:globalCurvatureEccentricity>
    <vdo:prototypeCurvatureCircularity></vdo:prototypeCurvatureCircularity>
    <vdo:prototypeCurvatureEccentricity></vdo:prototypeCurvatureEccentricity>
    <vdo:highestPeakY></vdo:highestPeakY>
    <vdo:numberOfPeaks>0</vdo:numberOfPeaks>
    </vdo:ContourShapeDescriptor>

  2. #2
    ciao.
    siccome nel tuo xml non ci sono i namespace .. se passi all xslt di cercare tst:blabla non lo trova ovviamente ..
    ho tolto i tst: da davanti gli elementi sul tuo xslt e funziona .....

    xslt

    codice:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="utf-8"/>
    <xsl:param name="instance" select="anonymous"/>
    <xsl:template match="/" xmlns:tst="urn:mpeg:mpeg7:schema:2001" xml:base="http://www.acemedia.org/fact-statements/PROTOTYPES#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema" xmlns:vdo="http://www.acemedia.org/ontologies/VDO#" xmlns:vdoext="http://www.acemedia.org/ontologies/VDO-EXT#">
    <vdo:ContourShapeDescriptor rdf:about="{$instance}">
    <xsl:variable name="gcevar" select="Mpeg7/DescriptionUnit/Descriptor/Region/GlobalCurvature"/>
    <xsl:variable name="gcevar1" select="substring-before($gcevar,' ')"/>
    <vdo:globalCurvatureCircularity>
    <xsl:value-of select="$gcevar1"/>
    </vdo:globalCurvatureCircularity>
    <xsl:variable name="gcevar2" select="substring-before(substring-after($gcevar,' '),' ')"/>
    <vdo:globalCurvatureEccentricity>
    <xsl:value-of select="$gcevar2"/>
    </vdo:globalCurvatureEccentricity>
    <xsl:variable name="pccvar" select="Mpeg7/DescriptionUnit/Descriptor/Region/PrototypeCurvature"/>
    <xsl:variable name="pccvar1" select="substring-before($pccvar,' ')"/>
    <vdo:prototypeCurvatureCircularity>
    <xsl:value-of select="$pccvar1"/>
    </vdo:prototypeCurvatureCircularity>
    <xsl:variable name="pccvar2" select="substring-before(substring-after($pccvar,' '),' ')"/>
    <vdo:prototypeCurvatureEccentricity>
    <xsl:value-of select="$pccvar2"/>
    </vdo:prototypeCurvatureEccentricity>
    <vdo:highestPeakY>
    <xsl:value-of select="Mpeg7/DescriptionUnit/Descriptor/Region/HighestPeakY"/>
    </vdo:highestPeakY>
    <xsl:for-each select="Mpeg7/DescriptionUnit/Descriptor/Region/Peak">
    <vdo:peakX>
    <xsl:value-of select="./@peakX"/>
    </vdo:peakX>
    </xsl:for-each>
    <xsl:for-each select="Mpeg7/DescriptionUnit/Descriptor/Region/Peak">
    <vdo:peakY>
    <xsl:value-of select="./@peakY"/>
    </vdo:peakY>
    </xsl:for-each>
    <vdo:numberOfPeaks>
    <xsl:value-of select="count(Mpeg7/DescriptionUnit/Descriptor/Region/Peak)"/>
    </vdo:numberOfPeaks>
    </vdo:ContourShapeDescriptor>
    </xsl:template>
    </xsl:stylesheet>
    xml

    codice:
    <?xml version='1.0' encoding='ISO-8859-1' ?>
    <?xml-stylesheet type="text/xsl" href="t_contourshape.xsl"?>
    <Mpeg7>
    <DescriptionUnit>
    <Descriptor>
    <Region>
    <RegionNumber>255</RegionNumber>
    <GlobalCurvature>7  3 </GlobalCurvature>
    <PrototypeCurvature>1  3 </PrototypeCurvature>
    <HighestPeakY>15</HighestPeakY>
    <Peak peakX="58" peakY="5"/>
    <Peak peakX="5" peakY="7"/>
    <Peak peakX="59" peakY="1"/>
    <Peak peakX="61" peakY="6"/>
    <Peak peakX="4" peakY="6"/>
    <Peak peakX="2" peakY="6"/>
    <Peak peakX="1" peakY="7"/>
    </Region>
    </Descriptor>
    </DescriptionUnit>
    </Mpeg7>

    trasformazione

    codice:
    <?xml version="1.0" encoding="utf-8"?>
    <vdo:ContourShapeDescriptor xmlns:vdo="http://www.acemedia.org/ontologies/VDO#" xmlns:tst="urn:mpeg:mpeg7:schema:2001" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema" xmlns:vdoext="http://www.acemedia.org/ontologies/VDO-EXT#" rdf:about="">
    <vdo:globalCurvatureCircularity>7</vdo:globalCurvatureCircularity>
    <vdo:globalCurvatureEccentricity/>
    <vdo:prototypeCurvatureCircularity>1</vdo:prototypeCurvatureCircularity>
    <vdo:prototypeCurvatureEccentricity/>
    <vdo:highestPeakY>15</vdo:highestPeakY>
    <vdo:peakX>58</vdo:peakX>
    <vdo:peakX>5</vdo:peakX>
    <vdo:peakX>59</vdo:peakX>
    <vdo:peakX>61</vdo:peakX>
    <vdo:peakX>4</vdo:peakX>
    <vdo:peakX>2</vdo:peakX>
    <vdo:peakX>1</vdo:peakX>
    <vdo:peakY>5</vdo:peakY>
    <vdo:peakY>7</vdo:peakY>
    <vdo:peakY>1</vdo:peakY>
    <vdo:peakY>6</vdo:peakY>
    <vdo:peakY>6</vdo:peakY>
    <vdo:peakY>6</vdo:peakY>
    <vdo:peakY>7</vdo:peakY>
    <vdo:numberOfPeaks>7</vdo:numberOfPeaks>
    </vdo:ContourShapeDescriptor>
    se serve na mano fammi sapere

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.