Click here to Skip to main content
15,881,715 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XML Pin
Member 1273144310-Sep-16 5:53
Member 1273144310-Sep-16 5:53 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 6:11
mveOriginalGriff10-Sep-16 6:11 
GeneralRe: XML Pin
Member 1273144310-Sep-16 6:40
Member 1273144310-Sep-16 6:40 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 7:23
mveOriginalGriff10-Sep-16 7:23 
QuestionHow to create XSD without repeating myself Pin
Mikael Sterley28-Apr-16 3:46
Mikael Sterley28-Apr-16 3:46 
AnswerRe: How to create XSD without repeating myself Pin
George Jonsson13-Jun-16 3:08
professionalGeorge Jonsson13-Jun-16 3:08 
AnswerRe: How to create XSD without repeating myself Pin
Bernhard Hiller5-Sep-16 21:08
Bernhard Hiller5-Sep-16 21:08 
Questiongenerating a unique value and adding it to a group of elements Pin
Drew Church27-Mar-16 14:11
Drew Church27-Mar-16 14:11 
Hello,

I am trying to generate a unique value for a set of elements and place an <id> element in each of the elements. They must have the same id but only the elements enclosed in an element like <envelope>. So my XML Document looks like:

XML
<noticeProduction type="c" revision="2015-11-10">
  <prologue type="c">
    <institutionId>22</institutionId>
    <institutionName>Test INC</institutionName>
    <databaseName>testdb</databaseName>
    <terminology option="S">Savings and Checking</terminology>
    <impoundTerminology option="E">Escrow</impoundTerminology>
    <productionDate>2016-21-03</productionDate>
    <productionTime>2016-21-15 23:52:33 EDT</productionTime>
    <reportTitle>Maturity Notice Production</reportTitle>
    <currentCutoffNoticeProductionSerial>1345</currentCutoffNoticeProductionSerial>
    <priorCutoffNoticeProductionSerial>345</priorCutoffNoticeProductionSerial>
  </prologue>
  <envelope type="a">
    <person type="a">
      <serial>5432</serial>
      <personLinkCategory option="PR">Primary owner</personLinkCategory>
      <firstName>Lynn</firstName>
      <lastName>Tanner</lastName>
      <contact type="a">
        <serial>5677</serial>
        <category option="BP">Business phone</category>
        <value>(111)111-1111</value>
      </contact>
      <contact type="a">
        <serial>2456</serial>
        <category option="PE">Personal email</category>
        <value>kkkkkkkkk@eirco423.net</value>
      </contact>
      <contact type="a">
        <serial>1135</serial>
        <category option="HP">Home phone</category>
        <value>(111)111-1111</value>
      </contact>
    </person>
    <person type="a">
      <serial>5805</serial>
      <personLinkCategory option="JT">Joint owner</personLinkCategory>
      <firstName>Ultra</firstName>
      <lastName>Tanner</lastName>
    </person>
    <address type="c">
      <serial>2456</serial>
      <addressSerial>4070</addressSerial>
      <category option="R">Residence</category>
      <street>43 Times Ping Two Rail Lane</street>
      <city>Thomas Co Commons Oreland</city>
    </address>
    <notice type="a">
      <serial>1587</serial>
      <category option="F">Force pay</category>
      <account type="c">
        <serial>4358</serial>
        <accountNumber>0000000000</accountNumber>
        <eStatementOption option="E">E-statement only</eStatementOption>
        <eStatementEmailAddress>tay3456fgee@eircom.net</eStatementEmailAddress>
        <share type="c">
          <serial>35688</serial>
          <id>0004</id>
          <description>Checking</description>
          <typeSerial>6</typeSerial>
          <typeDescription>Checking</typeDescription>
        </share>
      </account>
      <transactionSerial>98432123</transactionSerial>
      <monetarySerial>34563221</monetarySerial>
      <postingDate>2016-21-02</postingDate>
      <effectiveDate>2016-21-02</effectiveDate>
      <effectiveBalance>19.72</effectiveBalance>
      <effectiveBalanceResult>-1260.28</effectiveBalanceResult>
      <availableBalance>19.72</availableBalance>
      <availableBalanceResult>-1260.28</availableBalanceResult>
      <feePostAmount>30.00</feePostAmount>
      <feeDescription>Overdraft Fee</feeDescription>
      <item type="a">
        <serial>2378</serial>
        <postingItemSerial>6532</postingItemSerial>
        <category option="W">Withdrawal</category>
        <source option="a">ACH</source>
        <description>BANK OF AMERICA</description>
        <amount>1250.00</amount>
      </item>
    </notice>
  </envelope>
  <envelope type="a">
    <person type="a">
      <serial>25258</serial>
      <personLinkCategory option="PR">Primary owner</personLinkCategory>
      <firstName>Jamie</firstName>
      <middleName>M</middleName>
      <lastName>Daniels</lastName>
      <contact type="a">
        <serial>38439</serial>
        <category option="BP">Business phone</category>
        <value>(610)789-0190</value>
      </contact>
      <contact type="a">
        <serial>38440</serial>
        <category option="PE">Personal email</category>
        <value>hgkyfyfy@YMAIL.COM</value>
      </contact>
    </person>
    <notice type="a">
      <serial>1218</serial>
      <category option="F">Force pay</category>
      <account type="c">
        <serial>20003</serial>
        <accountNumber>0000000000</accountNumber>
        <share type="c">
          <serial>42452</serial>
          <id>0004</id>
          <description>Checking</description>
          <typeSerial>6</typeSerial>
          <typeDescription>Checking</typeDescription>
        </share>
      </account>
      <transactionSerial>77313790</transactionSerial>
      <monetarySerial>27773576</monetarySerial>
      <postingDate>2016-03-02</postingDate>
      <effectiveDate>2016-03-02</effectiveDate>
      <effectiveBalanceResult>-60.00</effectiveBalanceResult>
      <availableBalanceResult>-60.00</availableBalanceResult>
      <feePostAmount>30.00</feePostAmount>
      <feeDescription>Overdraft Fee</feeDescription>
      <item type="a">
        <serial>845</serial>
        <postingItemSerial>5418</postingItemSerial>
        <category option="W">Withdrawal</category>
        <source option="a">ACH</source>
        <description>USAA CHK-INTLOIORNT</description>
        <amount>30.00</amount>
      </item>
    </notice>
    <notice type="a">
      <serial>1743</serial>
      <category option="F">Force pay</category>
      <account type="c">
        <serial>20003</serial>
        <accountNumber>0000000000</accountNumber>
        <share type="c">
          <serial>42452</serial>
          <id>0000</id>
          <description>Checking</description>
          <typeSerial>6</typeSerial>
          <typeDescription>Checking</typeDescription>
        </share>
      </account>
      <transactionSerial>77768043</transactionSerial>
      <monetarySerial>77767950</monetarySerial>
      <postingDate>2016-03-02</postingDate>
      <effectiveDate>2016-03-02</effectiveDate>
      <effectiveBalance>-60.00</effectiveBalance>
      <effectiveBalanceResult>-220.00</effectiveBalanceResult>
      <availableBalance>-60.00</availableBalance>
      <availableBalanceResult>-220.00</availableBalanceResult>
      <feePostAmount>30.00</feePostAmount>
      <feeDescription>Overdraft Fee</feeDescription>
      <item type="a">
        <serial>1370</serial>
        <postingItemSerial>7439</postingItemSerial>
        <category option="W">Withdrawal</category>
        <source option="a">ACH</source>
        <description>USAA CHK-KJHHUU</description>
        <amount>130.00</amount>
      </item>
    </notice>
  </envelope>
  <epilogue type="c">
    <envelopeCount>825</envelopeCount>
    <noticeCount>1478</noticeCount>
  </epilogue>
</noticeProduction>


And XLST File looks like:
XML
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:output method="xml" indent="yes"/>
  
  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
  </xsl:template>


  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>


  <xsl:template match="text() | comment() | processing-instruction()">
    <xsl:copy/>
  </xsl:template>


  <!--Identity template, provides default behavior that copies all content into the output -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="envelope">
    
    <xsl:copy>
      <id>
        <xsl:value-of select="generate-id(.)"/>      
      </id>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    
  </xsl:template>
  
  <xsl:template match="person">
    <xsl:copy>
      <id>
        <xsl:value-of select="envelope/id"/>
      </id>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="contact">
    <xsl:copy>
      <id>
        <xsl:value-of select="generate-id(.)"/>
      </id>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="address">
    <xsl:copy>
      <id>
        <xsl:value-of select="generate-id(.)"/>
      </id>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="notice">
    <xsl:copy>
      <id>
        <xsl:value-of select="generate-id(.)"/>
      </id>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>


So I am trying to generate a unique id for envelope and take that value and copy the id to the <person>, <contact>, <notice> and
tags. The id must be the same for the envelope and the tags that are enclosed in the envelope. ANy ideas?

AnswerRe: generating a unique value and adding it to a group of elements Pin
Jim Meadors27-Mar-16 18:29
Jim Meadors27-Mar-16 18:29 
GeneralRe: generating a unique value and adding it to a group of elements Pin
Drew Church28-Mar-16 2:07
Drew Church28-Mar-16 2:07 
GeneralRe: generating a unique value and adding it to a group of elements Pin
Jim Meadors28-Mar-16 19:44
Jim Meadors28-Mar-16 19:44 
GeneralRe: generating a unique value and adding it to a group of elements Pin
Drew Church29-Mar-16 3:26
Drew Church29-Mar-16 3:26 
GeneralRe: generating a unique value and adding it to a group of elements Pin
Jim Meadors29-Mar-16 19:12
Jim Meadors29-Mar-16 19:12 
Questiontheory xml . help me Pin
Member 1216400424-Nov-15 5:29
Member 1216400424-Nov-15 5:29 
AnswerRe: theory xml . help me Pin
George Jonsson4-Dec-15 20:45
professionalGeorge Jonsson4-Dec-15 20:45 
QuestionXML parsing error --> #10; Pin
NJdotnetdev14-Jul-15 2:23
NJdotnetdev14-Jul-15 2:23 
AnswerRe: XML parsing error --> #10; Pin
User 41802545-Aug-15 2:27
User 41802545-Aug-15 2:27 
QuestionNETIQ Product Help needed. Pin
Member 1156144127-Mar-15 10:24
Member 1156144127-Mar-15 10:24 
AnswerRe: NETIQ Product Help needed. Pin
Richard Andrew x6427-Mar-15 14:14
professionalRichard Andrew x6427-Mar-15 14:14 
AnswerRe: NETIQ Product Help needed. Pin
Abhipal Singh19-May-15 5:07
professionalAbhipal Singh19-May-15 5:07 
Questioncopying attribute from one node to other Pin
ramina sen9-Feb-15 0:10
ramina sen9-Feb-15 0:10 
QuestionXSL: how to properly reference to xml field? Pin
Maciej Los16-Nov-14 9:05
mveMaciej Los16-Nov-14 9:05 
AnswerRe: XSL: how to properly reference to xml field? Pin
Richard Deeming17-Nov-14 2:52
mveRichard Deeming17-Nov-14 2:52 
GeneralRe: XSL: how to properly reference to xml field? Pin
Maciej Los17-Nov-14 4:25
mveMaciej Los17-Nov-14 4:25 
QuestionHow to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire30-Oct-14 3:53
professionalJohn Whitmire30-Oct-14 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.