xml - Unable to Select node with namespace attached -
i have next xml fragment
<?xml version="1.0" encoding="utf-8"?> <sheet version="1.0" xmlns:j="http://www.it.ojp.gov/jxdm/3.0.2"> <subject xmlns="http://www.it.ojp.gov/jxdm/3.0.2"> <personname> <persongivenname>edwin</persongivenname> <personmiddlename>j</personmiddlename> <personsurname>turner</personsurname> </personname> </subject> </sheet> i'm using trying select subject node next xslt
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:template match="/"> <html> <body> <xsl:value-of select="sheet/subject"/> </body> </html> </xsl:template> </xsl:stylesheet> i testing segment on http://www.shell-tools.net/index.php?op=xslt.
what happens if run transform xml written, select attribute doesn't match. however, if remove namespace subject node, correctly select data.
i'm looking syntax how create selection work namespace attached subject node how info received web service.
you need define alias namespace of sheet document. xsl should this:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0" xmlns:sheet="http://www.it.ojp.gov/jxdm/3.0.2" <--- define alias exclude-result-prefixes="sheet" <--- prevent xslt using namespace in output document > <xsl:template match="/"> <html> <body> <xsl:value-of select="sheet/sheet:subject"/> <--- utilize alias </body> </html> </xsl:template> </xsl:stylesheet> xml xslt xpath
No comments:
Post a Comment