Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml DublinCore/Prism名称空间/前缀_Xml_Xslt - Fatal编程技术网

Xml DublinCore/Prism名称空间/前缀

Xml DublinCore/Prism名称空间/前缀,xml,xslt,Xml,Xslt,具有需要将元素从转换为DublinCore或Prism命名空间(即dc:XXX或Prism:XXX)的xslt。我试图添加名称空间前缀,但仍然没有成功。下面的示例是将“PMISSN”替换为“prism:issn” xmlns:pam=”http://prismstandard.org/namespaces/pam/2.2/" xmlns:xhtml=”http://www.w3.org/1999/xhtml" xmlns:prism=”http://prismstandard.org/na

具有需要将元素从
转换为DublinCore或Prism命名空间(即
dc:XXX
Prism:XXX
)的xslt。我试图添加名称空间前缀,但仍然没有成功。下面的示例是将“PMISSN”替换为“prism:issn”


xmlns:pam=”http://prismstandard.org/namespaces/pam/2.2/" 
xmlns:xhtml=”http://www.w3.org/1999/xhtml" 
xmlns:prism=”http://prismstandard.org/namespaces/basic/2.2/" 
xmlns:pim=”http://prismstandard.org/namespaces/pim/2.2/" 
xmlns:dcterms=”http://purl.org/dc/terms/" 
xmlns:prl=”http://prismstandard.org/namespaces/prl/2.1/" 
xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
xmlns:pur=”http://prismstandard.org/namespaces/prismusagerights/2.1/" 
xmlns:dc=”http://purl.org/dc/elements/1.1/"

以下是我希望转换的文件的示例:

<CNVOUTPUT>
<ACTCD>A</ACTCD><TXTAVAIL>STORED</TXTAVAIL><TXTRIGHTS>YES</TXTRIGHTS><TPGAVAIL>NOT STORED</TPGAVAIL><TPGRIGHTS>NO</TPGRIGHTS><FPIAVAIL>STORED</FPIAVAIL><FPIRIGHTS>NO</FPIRIGHTS><PMINFO><PMID>17549</PMID><PMTTL><PTTL>Mag's</PTTL></PMTTL><PMQUAL>Toronto</PMQUAL><PMJCD>GMAC</PMJCD><PMISSN>00249262</PMISSN>

<PMCODEN>MCNMBC</PMCODEN><PMSTYP><PSCD>2</PSCD><PSDES>PERIODICAL</PSDES></PMSTYP></PMINFO><PCINFO><PCDATE><PCNDATE>19920127</PCNDATE><PCADATE>Jan 27, 1992</PCADATE></PCDATE><STDCITE><PCVOL>105</PCVOL><PCISSU>4</PCISSU></STDCITE></PCINFO><DOCINFO><DOCID>1703718</DOCID><CPR>Copyright Maclean Hunter Consumer Publications Jan 27, 1992</CPR><DTTL><TTL>Public Remarks on a Private Matter</TTL></DTTL><DCITE><PGC>1</PGC><SP>9</SP><DOCL>English</DOCL><DPG>9</DPG><XID>CBCAMCLE2678804</XID></DCITE><AUS><AU><AUNAME>Amiel, Barbara</AUNAME></AU></AUS><DOCTY>Commentary</DOCTY></DOCINFO><TEXT><TXT><PARA>No Text Available.</PARA></TXT></TEXT><IDX><ITY>General Subject Terms</ITY><ITM><DTY>General Subject Term</DTY><DTA>Journalism</DTA></ITM><ITM><DTY>General Subject Term</DTY><DTA>Journalistic ethics</DTA></ITM><ITY>Classification Codes</ITY><ITM><DTY>Classification Code</DTY><DTA>9172</DTA></ITM><ITM><DTY>Classification Expansion</DTY><DTA>Canada</DTA></ITM></IDX><ABS><SABS><PARA>A woman discusses her run-ins with with Canadian media.  Making matters more complicated is the fact that she is also a journalist.  Other journalists started writing about her past relationships.  She attributes the controversy to her success in the field.</PARA></SABS></ABS>
</CNVOUTPUT>

ASTOREDYESNOT StoredNo17549Mag'sTorontoGMAC00249262
MCNMBC2Periodical1992012720199210541703718版权所有麦克莱恩·亨特消费者出版物1992年1月27日关于私人物品的公开评论19英语9CBCAMCLE2678804AMIEL,Barbaracommentary无可用文本。一般主题术语一般主题术语新闻报道一般主题术语新闻道德分类代码分类代码9172分类扩展加拿大一名妇女讨论她与加拿大媒体的口角。更复杂的是,她也是一名记者。其他记者开始写她过去的恋情。她把这场争论归因于她在这一领域的成功。

您的代码中有一个bug。所有名称空间都应声明为根元素的属性
xsl:stylesheet

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pam="http://prismstandard.org/namespaces/pam/2.2/" 
    xmlns:xhtml="http://www.w3.org/1999/xhtml" 
    xmlns:prism="http://prismstandard.org/namespaces/basic/2.2/" 
    xmlns:pim="http://prismstandard.org/namespaces/pim/2.2/" 
    xmlns:dcterms="http://purl.org/dc/terms/" 
    xmlns:prl="http://prismstandard.org/namespaces/prl/2.1/" 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
    xmlns:pur="http://prismstandard.org/namespaces/prismusagerights/2.1/" 
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    exclude-result-prefixes="dc pur rdf prl dcterms pim prism xhtml pam">

您可以在这里看到结果:

Lagvian-谢谢-它运行,但在重命名的标记后添加了一堆名称空间。看来我的错误在某个地方?现在是另一个问题了,不是吗?请先将实际输入的xml添加到问题中。将代码添加到原始问题中。请参阅更新的解决方案-使用exclude result prefixes@user3783403可以实现您要查找的内容。当您不使用这些名称空间并且不希望它们出现在输出中时,为什么要声明所有这些名称空间?事实上,您实际使用的唯一名称空间是
xmlns:prism
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pam="http://prismstandard.org/namespaces/pam/2.2/" 
    xmlns:xhtml="http://www.w3.org/1999/xhtml" 
    xmlns:prism="http://prismstandard.org/namespaces/basic/2.2/" 
    xmlns:pim="http://prismstandard.org/namespaces/pim/2.2/" 
    xmlns:dcterms="http://purl.org/dc/terms/" 
    xmlns:prl="http://prismstandard.org/namespaces/prl/2.1/" 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
    xmlns:pur="http://prismstandard.org/namespaces/prismusagerights/2.1/" 
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    exclude-result-prefixes="dc pur rdf prl dcterms pim prism xhtml pam">
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:prism="http://prismstandard.org/namespaces/basic/2.2/" 
    xmlns:dc="http://purl.org/dc/elements/1.1/">