我正在尝试对XML文档进行转换.我的XML转换可以导致两种不同类型的基本元素,具体取决于某个元素的值:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/databean/data[@id='pkhfeed']/value/text()='200'">
<xsl:call-template name="StructureA">
<xsl:with-param name="structure" select="//databean" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="StructureB">
<xsl:with-param name="structure" select="//databean" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
然后使用自己的名称空间和schemaLocations创建StructureA或StructureB:
<StructureA xmlns="http://...">
Run Code Online (Sandbox Code Playgroud)
StructureA&B共享一些共同元素,因此这些元素在一个名为"xmlcommon.xslt"的单独文件中定义,两个结构都包含来自的模板.此xmlcommon文件没有定义默认命名空间,因为我希望它可以从StructureA或StructureB中定义的命名空间中使用.但是当我运行我的转换时,从公共文件中引入的任何模板都会产生空白的xmlns属性:
<StructureA xmlns="http://...">
<SharedElement xmlns="">Something</SharedElement>
</StructureA>
Run Code Online (Sandbox Code Playgroud)
验证时,然后使用空白名称空间而不是正确的父名称空间. 有谁知道如何阻止我的公共文件中的模板添加那些空白的xmlns属性?
这是公共文件的片段:
<xsl:stylesheet version="1.0" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="ControlledListStructure">
<xsl:param name="xmlElem" />
<xsl:param name="structure" />
<xsl:element name="{$xmlElem}">
<!-- Blah blah blah -->
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用XML Includes来帮助管理需要人和机器都可用的大型XML结构.
但是在尝试构建可以针对现有模式进行验证的XML文件时遇到了无数问题.这是我正在尝试做的简化示例.
我的"main.xml"文件无法验证.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Main.xml - This fails to validate. -->
<ns1:main xsi:schemaLocation="http://www.example.com/main main.xsd"
xmlns:ns1="http://www.example.com/main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude">
<name>String</name>
<xi:include href="child.xml"/> <!-- What I'm trying to do. -->
</ns1:main>
Run Code Online (Sandbox Code Playgroud)
"child.xml"文件可以作为独立文件进行验证.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Child.xml - This validates fine, as a standalone file. -->
<ns1:child xsi:schemaLocation="http://www.example.com/main main.xsd"
xmlns:ns1="http://www.example.com/main"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>String</name>
<age>String</age>
</ns1:child>
Run Code Online (Sandbox Code Playgroud)
这是我的架构:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Main.xsd - My Simplified Schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://www.example.com/main"
targetNamespace="http://www.example.com/main">
<!-- Main Element (References Child) -->
<xs:element name="main">
<xs:complexType>
<xs:sequence> …Run Code Online (Sandbox Code Playgroud) 如此真气,我几乎无法说话.我已经使用SimpleXML组装了一个RSS提要 - 但它正在使用名称空间,现在就是这样.但是,当输出时,它会不断尝试在根节点中声明xmlns:xmlns ="".即使我没有这样的事情.
它始于
$rssXML->addAttribute("version", '2.0');
$rssXML->addAttribute("xmlns:media", "http://search.yahoo.com/mrss/", '');
$rssXML->addAttribute("xmlns:dcterms", "http://purl.org/dc/terms/", '');
Run Code Online (Sandbox Code Playgroud)
在此之后我做: -
header("Content-Type: application/rss+xml");
echo $syndicationXML->asXML();
Run Code Online (Sandbox Code Playgroud)
然而它输出: -
<?xml version="1.0"?>
<rss xmlns:xmlns="" version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dcterms="http://purl.org/dc/terms/"><channel>...
Run Code Online (Sandbox Code Playgroud)
我不明白所有这个名称空间声明.这是怎么回事?
我在这里发现了类似的问题,但它不再帮助我了.但是我面临同样的问题.在运行我的应用程序时,我收到以下错误:
警告:页面/template/common.xhtml声明命名空间http://primefaces.org/ui并使用标记p:panel,但没有与命名空间关联的TagLibrary.
下面是我的index.xhtml的片段:
<ui:composition template="/template/common.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:define name="profile">
Run Code Online (Sandbox Code Playgroud)
这就是我的common.xhtml文件的外观(不是整个内容,只是命名空间和1-2行):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome to my website</title>
<h:outputStylesheet library="css" name="default.css" />
</h:head>
<h:body>
<div id="header" style="margin: auto; width: 80%;">
<p:panel>
Run Code Online (Sandbox Code Playgroud)
正如BalusC在这里所描述的那样,必须定义xmlns ="http://www.w3.org/1999/xhtml".我也是这样做的.即index.xhtml文件的第二行也是这样做的.但我仍然得到错误.
此问题与WPF应用程序有关.
我在Project" Common "中有一个如下课程.命名空间名称也相同.
namespace Common
{
public ViewBase : UserControl
{
// Code
}
}
Run Code Online (Sandbox Code Playgroud)
如果我将一个新的abc.XAML文件添加到同一个项目(Common)...我想从ViewBase类派生我的代码(abc.xaml.cs文件).
但在这种情况下如何在XAML文件中编写标题?
那是......应该如何引用我当前的名称空间?
<Namespace:ViewBase x:Class=""
xmlns:x=""
....>
Run Code Online (Sandbox Code Playgroud) 我有一个XSLT样式表,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:XQHeaderFunc="java:com.sonicsw.xq.service.xform.HeaderExtension"
xmlns:saxon="http://saxon.sf.net/">
<saxon:script language="java" implements-prefix="XQHeaderFunc" src="java:com.sonicsw.xq.service.xform.HeaderExtension" />
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="processId" select="XQHeaderFunc:getProperty(XQHeaderFunc:new(),'processId',-1)" />
<xsl:value-of select="XQHeaderFunc:setProperty(XQHeaderFunc:new(),'processId',string(@id),-1)"/>
<root>
<xsl:apply-templates />
</root>
</xsl:template>
<!-- Other stuff -->
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我想使用第二个XSLT样式表来转换此样式表,以删除与XQHeaderFunc和saxon命名空间有关的任何内容.有没有办法可以做到这一点?
我现在尝试了以下,成功处理元素,但命名空间声明似乎不想消失.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:XQHeaderFunc="java:com.sonicsw.xq.service.xform.HeaderExtension"
xmlns:saxon="http://saxon.sf.net/"
exclude-result-prefixes="XQHeaderFunc saxon">
<xsl:param name="XQHeaderReplacement" />
<xsl:variable name="apos">'</xsl:variable>
<!-- Copy all nodes -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- Remove saxon script tag -->
<xsl:template match="saxon:script" />
<!-- Remove elements with setProperty calls -->
<xsl:template match="*[starts-with(@select, 'XQHeaderFunc:setProperty')]" …Run Code Online (Sandbox Code Playgroud) 我在Spring Batch示例中看到了标签所在的位置(即<job></job>).但是在我的xml文件中,我必须包含'batch'.例如<batch:job></batch:job>
这是为什么?这是一个版本的东西吗?我想通过删除批处理来稀释标签:如果可能的话,在所有标签中删除标签.
我正在尝试使用Glassfish 4.0和Java EE 7 XML命名空间来测试下面的示例.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Title</title>
</h:head>
<h:body>
<h:form>
<ul>
<ui:repeat value="#{appLoad.movieList}" var="movie">
<li>
<h:link value="#{movie.title}" outcome="movie" includeViewParams="true">
<f:param name="id" value="#{movie.id}"/>
</h:link>
</li>
</ui:repeat>
</ul>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
它链接到以下页面movie.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<f:metadata>
<f:viewParam name="id" value="#{appLoad.movieId}"/>
<f:event listener="#{appLoad.movieDetail()}" type="preRenderView"/>
</f:metadata>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:panelGrid columns="1" width="400">
<h:panelGrid columns="1">
Title : <h:outputLabel value="#{appLoad.movie.title}"/>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
该#{appLoad}支持bean是
@ManagedBean
@RequestScoped
public class AppLoad { …Run Code Online (Sandbox Code Playgroud) 我有这个:
<html
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:selectOneRadio>
<f:selectItem value="1" itemValue="1" itemLabel="123"/>
<f:selectItem value="2" itemValue="2" itemLabel="321"/>
</h:selectOneRadio>
Run Code Online (Sandbox Code Playgroud)
我得到了这个:
<f:selectItem value="1" itemValue="1" itemLabel="123"></f:selectItem>
<f:selectItem value="2" itemValue="2" itemLabel="321"></f:selectItem>
<select name="j_idt5" size="1"></select>
Run Code Online (Sandbox Code Playgroud)
为什么xmlns:f="http://xmlns.jcp.org/jsf/core"标签没有呈现?
我在Netbeans 7.3上使用JBoss AS 7.
我是一个SOAP新手,并努力解决此错误消息,
{:错误,"500","未声明的名称空间前缀\"x \"\n在[row,col {unknown-source}]:[1,168]"}
对于下面的SOAP信封.由于我试图访问的主机系统的条款和条件,我已用"xxx"替换了识别URL和凭证信息,并删除了大多数对象.
<x:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:read="urn://xxx/sdk/ReadObject"
xmlns:obj="http://xxx/object">
<x:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>xxx</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxx</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</x:Header>
<x:Body>
<read:readEstimate>
<read:estimate>
<obj:id>38945</obj:id>
</read:estimate>
</read:readEstimate>
</x:Body>
</x:Envelope>
Run Code Online (Sandbox Code Playgroud)