小编Lac*_*che的帖子

如何在xslt中使用group by

我有一个拥有如此多元素的xml,其中大部分包含属性..对于某些属性值是相同的,所以我需要对它们进行分组并生成diff xml.I/p Ex:

<TestNode>
 <ABC1 value="10.7" format="$" />
 <ABC2 value="10.5" format="$" />
 <ABC3 value="20" format="Rs" />
 <ABC4 value="50" format="Rs" />
 <ABC5 value="10.5" format="$" />
</TestNode>
Run Code Online (Sandbox Code Playgroud)

我需要按格式对行进行分组. 注意:格式不固定......它可能会增长...... O/P Ex: 有可能获得吗?提前致谢...

xslt group-by

5
推荐指数
2
解决办法
6078
查看次数

如何从XSLT访问CDATA中的变量?

我正在使用XSLT转换,需要在CDATA部分放置一些数据,并且该值存在于变量中.

查询:如何访问CDATA中的变量?下面给出的样本:

<xsl:attribute name ="attributeName">
<![CDATA[ 
  I need to access some variable here like
   *<xsl:value-of select ="$AnyVarible"/>* 
 ]]>
</xsl:attribute>
Run Code Online (Sandbox Code Playgroud)

如何在CDATA中使用varibale?注意:我不能使用 - > &lt;![CDATA[<xsl:value-of select ="$AnyVarible"/>]]&gt; 提前谢谢.

xslt cdata

4
推荐指数
1
解决办法
1万
查看次数

编写XPath查询以根据属性和内容匹配元素

我有一些像这样的XML:

<topics>
  <topic id="50"/>
  <topic id="51"/>
  <topic id="52"/>
</topics>

<discussions>
  <discussion type="foo">talked about T50 as Discussion 1000</discussion>
  <discussion type="bar">Food is yummy!</discussion>
  <discussion type="foo">talked about T52 as Discussion 1050</discussion>
</discussions>
Run Code Online (Sandbox Code Playgroud)

给定一个特定的主题ID($topicID),我想做以下事情:

  • 设计一个XPath表达式,如果有包含该文本的<discussion>with type="foo",则为true T$topicID as Discussion <corresponding-discussion-id>.

  • 设计一个XPath表达式,给定$topicID它将提取文本Discussion <corresponding-discussion-id>.

这可能吗?


更新:

对于第一个,我想我需要这样的东西:

exists(
 //discussions/discussion[
  @type="foo" and
  contains(text(), concat($topicId, ??? ))  <-- What goes here? I think we need
 ]                                           some kind of matches(...) around the
)                                            concat(), too.
Run Code Online (Sandbox Code Playgroud)

string xslt xpath expression

4
推荐指数
1
解决办法
1522
查看次数

XPath表达式不返回//元素,但//*返回计数

我正在使用带有以下示例数据的XOM:

Element root = cleanDoc.getRootElement();
//find all the bold elements, as those mark institution and clinic.
Nodes nodes = root.query("//*");

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">
    <head>
        <title>Patient Information</title>
    </head>
</html>
Run Code Online (Sandbox Code Playgroud)

以下元素返回许多元素(来自实际数据):

//*
Run Code Online (Sandbox Code Playgroud)

但有点像

//head
Run Code Online (Sandbox Code Playgroud)

什么都不返回 如果我遍历根的子节点,数字似乎匹配,如果我打印元素名称,一切看起来都是正确的.

我正在使用HTML,使用tagsoup解析它,然后从结果字符串构建XOM文档.这部分可能会出现如此可怕的错误?我觉得这里有一些奇怪的编码问题,但我只是没有看到它.Java字符串是字符串,对吧?

java xpath tag-soup xml-namespaces xom

4
推荐指数
1
解决办法
1571
查看次数

使用特殊字符解析XML(UTF-8)

我开始使用一些看起来像这样的XML(简化):

<?xml version="1.0" encoding="UTF-8"?>
<alldata>
   <data name="Forsetì" />
</alldata>
</xml>
Run Code Online (Sandbox Code Playgroud)

但是在我用simplexml_load_string特殊字符(i)解析之后,它变得ì非常明显.

有没有办法防止这种情况发生?

我知道XML很好,当保存为.txt并在浏览器中查看时,字符很好.当我在XML上使用simplexml_load_string然后将值保存为文本文件或数据库时,它会被破坏.

php xml encoding utf-8

4
推荐指数
1
解决办法
1万
查看次数

检测performSelectorInBackground的结束:withObject:

我的iOS应用程序中有异步服务器请求:

[self performSelectorInBackground:@selector(doSomething) withObject:nil];
Run Code Online (Sandbox Code Playgroud)

如何检测此操作的结束?

iphone multithreading detect nsthread ios

4
推荐指数
1
解决办法
4505
查看次数

NSTimeInterval可读取NSNumber

NSTimeInterval == double; (例如169.12345666663)

如何围绕这个双倍,以便"点"后只剩下2位数?
如果结果是NSNumber,那将是非常好的.

floating-point double cocoa objective-c rounding

3
推荐指数
1
解决办法
8939
查看次数

XSLT分组和子分组

我有以下代码:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" />

  <xsl:key name="categories" match="Category" use="." />
  <xsl:key name="clients" match="Category" use ="Category/Client" />

  <xsl:template match="/">
    <ul id="red" class="treeview-red">
      <xsl:for-each select="/Promotions/Promotion/Category[  
        generate-id(.) = generate-id(key('categories', .)[1])  
      ]">
        <xsl:variable name="cname" select="." />

        <li>
          <span>
            <xsl:value-of select="$cname" />
          </span>

          <xsl:for-each select="/Promotions/Promotion[Category=$cname]">
            <ul>
              <li>
                <span>
                  <xsl:value-of select="Client" />
                </span>
              </li>
              <ul>
                <li>
                  <span>
                    <xsl:value-of select="Title" />
                  </span>
                </li>
              </ul>
            </ul>
          </xsl:for-each>
        </li>
      </xsl:for-each>

    </ul>
  </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

我的XML:

<Promotions>
  <Promotion>
    <Category>Arts &amp; Entertainment</Category>
    <Client>Client 1</Client>
    <Title>Get your Free 2</Title>
  </Promotion>
  <Promotion> …
Run Code Online (Sandbox Code Playgroud)

xslt xsl-grouping muenchian-grouping

3
推荐指数
1
解决办法
2118
查看次数

如何创建自定义UIButton(带图像)但仍然使用setTitle?

我尝试用UIButtonTypeCustom创建一个UIButton.然后使用以下方法调整它的外观

[sendButton setImage:[UIImage imageNamed:@"sendButtonOff.png"] forState:UIControlStateNormal];
[sendButton setImage:[UIImage imageNamed:@"sendButtonOn.png"] forState:UIControlStateHighlighted];      
[sendButton setImage:[UIImage imageNamed:@"sendButtonDisabled.png"] forState:UIControlStateDisabled];
Run Code Online (Sandbox Code Playgroud)

但问题是,一旦你开始将UIImages设置为状态,setTitle就不再有效了.我认为setTitle只适用于非UIButtonTypeCustom?这意味着我要么必须将文本放入图像本身(不是很健壮),要么将其子类化并在视图中添加UILabel?听起来很多工作:(任何想法?

iphone background-image uibutton

2
推荐指数
1
解决办法
3218
查看次数

如何在iPhone上创建多按钮确认?

在iPhone上,当您按下"删除事件"按钮时,在日历应用程序中,确认从底部滑入.有没有人知道这个的任何示例代码,还是只是一个简短的视图呈现模式与自定义背景?

如果这是使用自定义视图进行的,您是否知道我可以在哪里获得与日历应用程序中使用的背景图形相同的背景图形?

提前致谢!

注意:我不是在谈论UIAlertView对话框,而是带有多个按钮的滑入式确认.

iphone sdk uikit uialertview uiactionsheet

2
推荐指数
1
解决办法
1271
查看次数

我如何安装org.apache.commons.code.binary.Base64?

我在Android上上课,我是JDeveloper的新手.我正在研究Web服务应用程序.我下载了一些包含"Import org.apache.commons.binary.Base64"的代码.这个导入JDeveloper正在"找不到".我在apache网站上找到了org.apache.commons.binary.Base64模块并下载了它.现在我该怎么做?我不确定如何或在何处放置此代码.下载的文件夹有几个文件夹,其中一个文件夹的底部是我的Base64模块.对不起这个基本问题.我正在使用在Windows 7上运行的JDeveloper 11g 11.1.1.0.2.

java jdeveloper apache-commons

1
推荐指数
1
解决办法
7994
查看次数

滚动时UITableView无法正确更新

我正在编写一个包含2个部分的UITableView.当表首次加载时,所有单元格都显示正确的信息,但是当我开始向上和向下滚动时,单元格detailTextLabel和accessoryType正在被错误地刷新,这样一些应该只包含detailTextLabel的单元格也包含一个附件,并且应该只包含一个附件也包含一个详细的TextLabel.

在内部cellForRowAtIndexPath:我使用嵌套的switch/case语句将正确的值应用于各自的section/row中的单元格.至于我可以说这些陈述中的逻辑是正确的,那么cell更新时变量的值是否可能是正确的?

该表正确加载但滚动后的accessoryType和detailedTextLabel混淆了.

单击以链接到表格的屏幕截图.

这是我的UITableViewController子类中的代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [sectionNames count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    NSArray *headingsSection = [cellTitles objectAtIndex:section];
    return [headingsSection count]; 
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [sectionNames objectAtIndex:section];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    self.tableView.allowsSelection = YES;
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview tableview

1
推荐指数
1
解决办法
2224
查看次数