문제

XSLT를 사용하여 HTML 컨트롤을 출력하고 싶지만 양식이 다시 게시 될 때 컨트롤을 얻을 수 있도록 컨트롤의 이름을 지정할 수 있어야합니다.

라디오 버튼의 이름을 지정하고 싶습니다. "action_" + _case_id.

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<NewDataSet>
  <Cases>
    <Case>
      <case_id>30</case_id>
    </Case>
  <Cases>
</NewDataSet>

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
     <div class="your_action">
      Your action:<br />
      <input type="radio" name="?" value="No" checked ="true"/> nothing to report<br />
      <input type="radio" name="?" value="Yes" /> memo to follow
    </div>
  </xsl:template>
</xsl:stylesheet>
도움이 되었습니까?

해결책

사용:

u003Cinput type="radio" name="{concat('action_', /*/*/*/case_id)}"n value="No" checked ="true"/>

XML 문서가 변경되면 위의 "*"숯을보다 자세한 위치 단계로 대체해야 할 수도 있습니다.

다른 팁

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<NewDataSet>
  <Cases>
    <Case>
      <case_id>30</case_id>
    </Case>
  <Cases>
</NewDataSet>

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
     <xsl:variable name="actionid">action_<xsl:value-of select="Cases/Case/case_id"/></xsl:variable>
     <div class="your_action">
      Your action:<br />
      <input type="radio" name="{actionid}" value="No" checked ="true"/> nothing to report<br />
      <input type="radio" name="{actionid}" value="Yes" /> memo to follow
    </div>
  </xsl:template>
</xsl:stylesheet>

참고 : 테스트되지 않았습니다. 루트 노드에서 일치하지 않고 케이스 노드에 대해 특별히 매치자를 추가하고 싶을 것입니다.

참조 할 때 $ 부호로 변수를 접두사해야합니다.

<input type="radio" name="{$actionid}" value="No" checked ="true"/> nothing to report<br />

귀하의 데이터 세트에는 트리라는 멋진 속성이 있으며 각 노드는 트리의 경로로 식별 할 수 있습니다. 최선의 방법은 다음을 반영하는 방식으로 각 XML 노드에 해당하는 컨트롤을 지정하는 것입니다.

  1. newDataset_cases_case1_case_id1_rb.
  2. newDataset_cases_case1_case_id2_rb.

부모 노드의 이름을 얻는 방법이 필요합니다.

&lt;xsl:variable name="parent1Name"
              select="name(parent::*)" /&gt;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top